Removed the inline functions from SDL_stdinc.h

Having the SDL functions inline is causing build issues, and in the case of malloc(), etc. causing malloc/free mismatches, if the application build environment differs from the SDL build environment.

In the interest of safety and consistency, the functions will always be in the SDL library and will only be redirected to the C library there, if they are available.

See the following threads on the SDL mailing list for the gruesome details:
* SDL_stdinc.h inlines problematic when application not compiled in exact same feature environment
* Error compiling program against SDL2 with -std=c++11 g++ flag
This commit is contained in:
Sam Lantinga 2013-07-05 23:57:19 -07:00
parent 3a78485f2d
commit cfd541e89c
9 changed files with 469 additions and 788 deletions

View file

@ -24,16 +24,27 @@
#include "SDL_stdinc.h"
#ifdef SDL_malloc
/* expose the symbol, but use what we figured out elsewhere. */
#undef SDL_malloc
#undef SDL_calloc
#undef SDL_realloc
#undef SDL_free
void *SDL_malloc(size_t size) { return SDL_malloc_inline(size); }
void *SDL_calloc(size_t nmemb, size_t size) { return SDL_calloc_inline(nmemb, size); }
void *SDL_realloc(void *ptr, size_t size) { return SDL_realloc_inline(ptr, size); }
void SDL_free(void *ptr) { SDL_free_inline(ptr); }
#if defined(HAVE_MALLOC)
void *SDL_malloc(size_t size)
{
return malloc(size);
}
void *SDL_calloc(size_t nmemb, size_t size)
{
return calloc(nmemb, size);
}
void *SDL_realloc(void *ptr, size_t size)
{
return realloc(ptr, size);
}
void SDL_free(void *ptr)
{
free(ptr);
}
#else /* the rest of this is a LOT of tapdancing to implement malloc. :) */