From f4938bfa4d81abf59c89fb0d0c4c942df10754e3 Mon Sep 17 00:00:00 2001 From: Sean Barrett Date: Sat, 27 Aug 2016 12:09:01 -0700 Subject: [PATCH 1/2] Whitelist the compilers that need malloc.h for alloca --- stb_vorbis.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stb_vorbis.c b/stb_vorbis.c index 19459eb..620440d 100644 --- a/stb_vorbis.c +++ b/stb_vorbis.c @@ -553,12 +553,12 @@ enum STBVorbisError #include #include #include -#if !(defined(__APPLE__) || defined(MACOSX) || defined(macintosh) || defined(Macintosh)) +#ifdef _MSC_VER #include +#endif #if defined(__linux__) || defined(__linux) || defined(__EMSCRIPTEN__) #include #endif -#endif #else // STB_VORBIS_NO_CRT #define NULL 0 #define malloc(s) 0 From 14e6a98469d8f378e5f6a1d77d166244fe452d6c Mon Sep 17 00:00:00 2001 From: Sean Barrett Date: Sat, 27 Aug 2016 12:10:46 -0700 Subject: [PATCH 2/2] clarify alloca #include whitelists --- stb_vorbis.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/stb_vorbis.c b/stb_vorbis.c index 620440d..c4f24d5 100644 --- a/stb_vorbis.c +++ b/stb_vorbis.c @@ -549,21 +549,23 @@ enum STBVorbisError #endif #ifndef STB_VORBIS_NO_CRT -#include -#include -#include -#include -#ifdef _MSC_VER -#include -#endif -#if defined(__linux__) || defined(__linux) || defined(__EMSCRIPTEN__) -#include -#endif + #include + #include + #include + #include + + // find definition of alloca if it's not in stdlib.h: + #ifdef _MSC_VER + #include + #endif + #if defined(__linux__) || defined(__linux) || defined(__EMSCRIPTEN__) + #include + #endif #else // STB_VORBIS_NO_CRT -#define NULL 0 -#define malloc(s) 0 -#define free(s) ((void) 0) -#define realloc(s) 0 + #define NULL 0 + #define malloc(s) 0 + #define free(s) ((void) 0) + #define realloc(s) 0 #endif // STB_VORBIS_NO_CRT #include