# HG changeset patch # User Matti Hamalainen # Date 1425532943 -7200 # Node ID fa59b65149e68a52c12c6e498466800b77b8b231 # Parent aa3738b121d1b984576d83216ff177b332ed23b3 Get rid of string.h dependency in stb_image. diff -r aa3738b121d1 -r fa59b65149e6 src/stb_image.c --- a/src/stb_image.c Thu Mar 05 07:19:05 2015 +0200 +++ b/src/stb_image.c Thu Mar 05 07:22:23 2015 +0200 @@ -534,7 +534,6 @@ #include #include // ptrdiff_t on osx #include -#include #if !defined(STBI_NO_LINEAR) || !defined(STBI_NO_HDR) #include // ldexp @@ -576,6 +575,7 @@ #define STBI_MALLOC(sz) malloc(sz) #define STBI_REALLOC(p,sz) realloc(p,sz) #define STBI_FREE(p) free(p) +#define STBI_MEMSET(p, v, s) memset(p,v,s) #endif #if defined(__GNUC__) && !defined(__SSE2__) && !defined(STBI_NO_SIMD) @@ -1390,7 +1390,7 @@ h->maxcode[j] = 0xffffffff; // build non-spec acceleration table; 255 is flag for not-accelerated - memset(h->fast, 255, 1 << FAST_BITS); + STBI_MEMSET(h->fast, 255, 1 << FAST_BITS); for (i=0; i < k; ++i) { int s = h->size[i]; if (s <= FAST_BITS) { @@ -1570,7 +1570,7 @@ if (t < 0) return stbi__err("bad huffman code","Corrupt JPEG"); // 0 all the ac values now so we can do it 32-bits at a time - memset(data,0,64*sizeof(data[0])); + STBI_MEMSET(data,0,64*sizeof(data[0])); diff = t ? stbi__extend_receive(j, t) : 0; dc = j->img_comp[b].dc_pred + diff; @@ -1622,7 +1622,7 @@ if (j->succ_high == 0) { // first scan for DC coefficient, must be first - memset(data,0,64*sizeof(data[0])); // 0 all the ac values now + STBI_MEMSET(data,0,64*sizeof(data[0])); // 0 all the ac values now t = stbi__jpeg_huff_decode(j, hdc); diff = t ? stbi__extend_receive(j, t) : 0; @@ -4577,7 +4577,7 @@ pixelCount = w*h; // Initialize the data to zero. - //memset( out, 0, pixelCount * 4 ); + //STBI_MEMSET( out, 0, pixelCount * 4 ); // Finally, the image data. if (compression) { @@ -4860,7 +4860,7 @@ // intermediate buffer is RGBA result = (Uint8 *) stbi__malloc(x*y*4); - memset(result, 0xff, x*y*4); + STBI_MEMSET(result, 0xff, x*y*4); if (!stbi__pic_load_core(s,x,y,comp, result)) { STBI_FREE(result); @@ -5210,7 +5210,7 @@ { Uint8 *u = 0; stbi__gif g; - memset(&g, 0, sizeof(g)); + STBI_MEMSET(&g, 0, sizeof(g)); u = stbi__gif_load_next(s, &g, comp, req_comp); if (u == (Uint8 *) s) u = 0; // end of animated gif marker