Remap stb_vorbis malloc/free calls to RL_MALLOC/RL_FREE

Added STB_VORBIS_MALLOC and STB_VORBIS_FREE hooks to stb_vorbis.c,
consistent with the named macro pattern used by dr_wav, dr_mp3, and qoa.
This commit is contained in:
nadav78 2026-04-16 01:22:09 +03:00
parent 9b5867adaf
commit 42a7d818bd
2 changed files with 10 additions and 4 deletions

View File

@ -957,13 +957,21 @@ static void *setup_malloc(vorb *f, int sz)
f->setup_offset += sz;
return p;
}
#ifdef STB_VORBIS_MALLOC
return sz ? STB_VORBIS_MALLOC(sz) : NULL;
#else
return sz ? malloc(sz) : NULL;
#endif
}
static void setup_free(vorb *f, void *p)
{
if (f->alloc.alloc_buffer) return; // do nothing; setup mem is a stack
#ifdef STB_VORBIS_FREE
STB_VORBIS_FREE(p);
#else
free(p);
#endif
}
static void *setup_temp_malloc(vorb *f, int sz)

View File

@ -210,11 +210,9 @@ typedef struct tagBITMAPINFOHEADER {
#endif
#if SUPPORT_FILEFORMAT_OGG
#define malloc RL_MALLOC
#define free RL_FREE
#define STB_VORBIS_MALLOC RL_MALLOC
#define STB_VORBIS_FREE RL_FREE
#include "external/stb_vorbis.c" // OGG loading functions
#undef malloc
#undef free
#endif
#if SUPPORT_FILEFORMAT_MP3