Skip to content

Commit bf77fc5

Browse files
committed
stbi: make static
not to spoil the global namespace + since some functions are not used, it may also save a few bytes in build + revert warning fixes in stbi_image.h in the commit df3330d since no longer needed - vanilla version is used now
1 parent 53d7161 commit bf77fc5

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

src/utils/image_delegate.c

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,24 @@
4646
#define strtok_s strtok_r
4747
#endif
4848

49+
4950
#include "../gpujpeg_common_internal.h"
5051
#include "../../libgpujpeg/gpujpeg_decoder.h" // ddecoder placeholders
5152
#include "image_delegate.h"
5253
#include "pam.h"
53-
#define STB_IMAGE_WRITE_IMPLEMENTATION
54-
#include "stb_image_write.h"
5554
#include "y4m.h"
5655

56+
enum {
57+
DEPTH_8B = 8,
58+
MAXVAL_8B = 255,
59+
};
60+
61+
// stbi_image and stbi_image_write include
62+
#ifdef __GNUC__
63+
#pragma GCC diagnostic push
64+
#pragma GCC diagnostic ignored "-Wunused-function"
65+
#endif
66+
5767
static void
5868
gpujpeg_cuda_free_host(void* ptr);
5969
static void*
@@ -68,12 +78,16 @@ gpujpeg_cuda_realloc_sized_host(void* ptr, int oldsz, int newsz);
6878
#define STBI_FREE gpujpeg_cuda_free_host
6979
#define STBI_REALLOC_SIZED gpujpeg_cuda_realloc_sized_host
7080
#define STB_IMAGE_IMPLEMENTATION
81+
#define STB_IMAGE_STATIC
7182
#include "stb_image.h"
7283

73-
enum {
74-
DEPTH_8B = 8,
75-
MAXVAL_8B = 255,
76-
};
84+
#define STB_IMAGE_WRITE_IMPLEMENTATION
85+
#define STB_IMAGE_WRITE_STATIC
86+
#include "stb_image_write.h"
87+
88+
#ifdef __GNUC__
89+
#pragma GCC diagnostic pop
90+
#endif
7791

7892
static void
7993
gpujpeg_cuda_free_host(void* ptr)

src/utils/stb_image.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,7 +1066,6 @@ static void *stbi__malloc_mad4(int a, int b, int c, int d, int add)
10661066
}
10671067
#endif
10681068

1069-
#ifndef STBI_NO_JPEG
10701069
// returns 1 if the sum of two signed ints is valid (between -2^31 and 2^31-1 inclusive), 0 on overflow.
10711070
static int stbi__addints_valid(int a, int b)
10721071
{
@@ -1083,7 +1082,6 @@ static int stbi__mul2shorts_valid(int a, int b)
10831082
if (b < 0) return a <= SHRT_MIN / b; // same as a * b >= SHRT_MIN
10841083
return a >= SHRT_MIN / b;
10851084
}
1086-
#endif
10871085

10881086
// stbi__err - error
10891087
// stbi__errpf - error returning pointer to float
@@ -7675,7 +7673,6 @@ static int stbi__info_main(stbi__context *s, int *x, int *y, int *comp)
76757673

76767674
static int stbi__is_16_main(stbi__context *s)
76777675
{
7678-
(void) s;
76797676
#ifndef STBI_NO_PNG
76807677
if (stbi__png_is16(s)) return 1;
76817678
#endif

0 commit comments

Comments
 (0)