diff --git a/docs/other_libs.md b/docs/other_libs.md index e00f37f..56f19cd 100644 --- a/docs/other_libs.md +++ b/docs/other_libs.md @@ -15,7 +15,7 @@ free to tell me about their quality.) _Newest additions are in italics._ - **network** [zed_net](https://github.com/ZedZull/zed_net): cross-platform socket wrapper (public domain) - **strings**; **files & filenames** [DG_misc.h](https://github.com/DanielGibson/Snippets/): Daniel Gibson's stb.h-esque cross-platform helpers: path/file, strings (public domain) - **strings** [utf8](https://github.com/sheredom/utf8.h): utf8 string library (public domain) -- _**strings** [strpool.h](https://github.com/mattiasgustavsson/libs): string interning (public domain/MIT)_ +- **strings** [strpool.h](https://github.com/mattiasgustavsson/libs): string interning (public domain/MIT) - **misc** [MakeID.h](http://www.humus.name/3D/MakeID.h): allocate/deallocate small integer IDs efficiently (public domain) - **misc** [gb_string.h](https://github.com/gingerBill/gb): dynamic strings for C (public domain) - **misc** [loguru](https://github.com/emilk/loguru): flexible logging for C++ (public domain) @@ -28,21 +28,26 @@ Not public domain: - **images** [nanoSVG](https://github.com/memononen/nanosvg): 1-file SVG parser; 1-file SVG rasterizer (zlib license) - **3D** [tinyobjloader](https://github.com/syoyo/tinyobjloader): wavefront OBJ file loader (BSD license) - **2D** [blendish](https://bitbucket.org/duangle/oui-blendish/src): blender-style widget rendering (MIT license) -- _**math** [mm_vec.h](https://github.com/vurtun/mmx): vector math (BSD license)_ +- **math** [mm_vec.h](https://github.com/vurtun/mmx): vector math (BSD license) - **geometry** [sdf.h](https://github.com/memononen/SDF): compute signed-distance field from antialiased image (MIT license) - **geometry** [nanoflann](https://github.com/jlblancoc/nanoflann): build KD trees for point clouds (BSD license) - **geometry** [jc_voronoi](https://github.com/JCash/voronoi): find voronoi regions on float/double data (MIT license) +- **geometry** [par_msquares](https://github.com/prideout/par): convert (binarized) image to triangles (MIT license) +- **geometry** [tk_objfile](https://github.com/joeld42/tk_objfile): OBJ file loader (MIT license) +- _**geometry** [par_shapes](http://github.prideout.net/shapes/): generate various 3d geometric shapes (MIT license)_ - **network** [mm_web.h](https://github.com/vurtun/mmx): lightweight webserver, fork of webby (BSD license) +- **network** [par_easycurl.h](https://github.com/prideout/par): curl wrapper (MIT license) - **audio** [aw_ima.h](https://github.com/afterwise/aw-ima/blob/master/aw-ima.h): IMA-ADPCM audio decoder (MIT license) -- **multithreading** [mm_sched.h](https://github.com/vurtun/mts): cross-platform multithreaded task scheduler (zlib license) +- **multithreading** [mm_sched.h](https://github.com/vurtun/mmx): cross-platform multithreaded task scheduler (zlib license) - **parsing** [SLRE](https://github.com/cesanta/slre): regular expression matcher (GPL v2) - **parsing** [PicoJSON](https://github.com/kazuho/picojson): JSON parse/serializer for C++ (BSD license) -- _**parsing** [mm_json.h](https://github.com/vurtun/mmx): JSON parser (zlib license)_ -- _**parsing** [mm_lexer.h](https://github.com/vurtun/mmx): C-esque language lexer (zlib license)_ +- **parsing** [mm_json.h](https://github.com/vurtun/mmx): JSON parser (zlib license) +- **parsing** [mm_lexer.h](https://github.com/vurtun/mmx): C-esque language lexer (zlib license) - **tests** [utest](https://github.com/evolutional/utest): unit testing (MIT license) - **tests** [catch](https://github.com/philsquared/Catch): unit testing (Boost license) - **tests** [SPUT](http://www.lingua-systems.com/unit-testing/): unit testing (BSD license) - **misc** [lualite](https://github.com/janezz55/lualite/): generate lua bindings in C++ (MIT license) +- **misc** [tinyformat](https://github.com/c42f/tinyformat): C++ typesafe printf (Boost license) There are some that have a source file and require a separate header file (which they may not even supply). That's twice as many files, and we at nothings/stb cannot condone diff --git a/stb_image.h b/stb_image.h index 6faf88c..e2a89ef 100644 --- a/stb_image.h +++ b/stb_image.h @@ -630,9 +630,9 @@ typedef unsigned char validate_uint32[sizeof(stbi__uint32)==4 ? 1 : -1]; #endif #ifndef STBI_MALLOC -#define STBI_MALLOC(sz) malloc(sz) -#define STBI_REALLOC(p,sz) realloc(p,sz) -#define STBI_FREE(p) free(p) +#define STBI_MALLOC(sz) malloc(sz) +#define STBI_REALLOC(p,oldsz,newsz) realloc(p,newsz) +#define STBI_FREE(p) free(p) #endif // x86/x64 detection @@ -3608,14 +3608,14 @@ stbi_inline static int stbi__zhuffman_decode(stbi__zbuf *a, stbi__zhuffman *z) static int stbi__zexpand(stbi__zbuf *z, char *zout, int n) // need to make room for n bytes { char *q; - int cur, limit; + int cur, limit, old_limit; z->zout = zout; if (!z->z_expandable) return stbi__err("output buffer limit","Corrupt PNG"); cur = (int) (z->zout - z->zout_start); - limit = (int) (z->zout_end - z->zout_start); + limit = old_limit = (int) (z->zout_end - z->zout_start); while (cur + n > limit) limit *= 2; - q = (char *) STBI_REALLOC(z->zout_start, limit); + q = (char *) STBI_REALLOC(z->zout_start, old_limit, limit); if (q == NULL) return stbi__err("outofmem", "Out of memory"); z->zout_start = q; z->zout = q + cur; @@ -4400,11 +4400,12 @@ static int stbi__parse_png_file(stbi__png *z, int scan, int req_comp) if (scan == STBI__SCAN_header) { s->img_n = pal_img_n; return 1; } if ((int)(ioff + c.length) < (int)ioff) return 0; if (ioff + c.length > idata_limit) { + stbi__uint32 idata_limit_old = idata_limit; stbi_uc *p; if (idata_limit == 0) idata_limit = c.length > 4096 ? c.length : 4096; while (ioff + c.length > idata_limit) idata_limit *= 2; - p = (stbi_uc *) STBI_REALLOC(z->idata, idata_limit); if (p == NULL) return stbi__err("outofmem", "Out of memory"); + p = (stbi_uc *) STBI_REALLOC(z->idata, idata_limit_old, idata_limit); if (p == NULL) return stbi__err("outofmem", "Out of memory"); z->idata = p; } if (!stbi__getn(s, z->idata+ioff,c.length)) return stbi__err("outofdata","Corrupt PNG"); diff --git a/stb_image_write.h b/stb_image_write.h index 38d3835..c737bb4 100644 --- a/stb_image_write.h +++ b/stb_image_write.h @@ -166,9 +166,9 @@ STBIWDEF int stbi_write_hdr_to_func(stbi_write_func *func, void *context, int w, #endif #ifndef STBIW_MALLOC -#define STBIW_MALLOC(sz) malloc(sz) -#define STBIW_REALLOC(p,sz) realloc(p,sz) -#define STBIW_FREE(p) free(p) +#define STBIW_MALLOC(sz) malloc(sz) +#define STBIW_REALLOC(p,oldsz,newsz) realloc(p,newsz) +#define STBIW_FREE(p) free(p) #endif #ifndef STBIW_MEMMOVE #define STBIW_MEMMOVE(a,b,sz) memmove(a,b,sz) @@ -647,7 +647,7 @@ int stbi_write_hdr(char const *filename, int x, int y, int comp, const float *da static void *stbiw__sbgrowf(void **arr, int increment, int itemsize) { int m = *arr ? 2*stbiw__sbm(*arr)+increment : increment+1; - void *p = STBIW_REALLOC(*arr ? stbiw__sbraw(*arr) : 0, itemsize * m + sizeof(int)*2); + void *p = STBIW_REALLOC(*arr ? stbiw__sbraw(*arr) : 0, *arr ? (stbiw__sbm(*arr)*itemsize + sizeof(int)*2) : 0, itemsize * m + sizeof(int)*2); STBIW_ASSERT(p); if (p) { if (!*arr) ((int *) p)[1] = 0;