Removed the limit on the size of the SDL error message
Also added SDL_GetOriginalMemoryFunctions() Fixes https://github.com/libsdl-org/SDL/issues/5795
This commit is contained in:
parent
f25b4b2774
commit
cbd0187475
11 changed files with 126 additions and 16 deletions
|
@ -71,11 +71,25 @@ static void SDL_InitDynamicAPI(void);
|
|||
|
||||
#define SDL_DYNAPI_VARARGS(_static, name, initcall) \
|
||||
_static int SDLCALL SDL_SetError##name(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) { \
|
||||
char buf[512]; /* !!! FIXME: dynamic allocation */ \
|
||||
char buf[128], *str = buf; \
|
||||
int result; \
|
||||
va_list ap; initcall; va_start(ap, fmt); \
|
||||
jump_table.SDL_vsnprintf(buf, sizeof (buf), fmt, ap); \
|
||||
result = jump_table.SDL_vsnprintf(buf, sizeof(buf), fmt, ap); \
|
||||
if (result >= 0 && (size_t)result >= sizeof(buf)) { \
|
||||
size_t len = (size_t)result + 1; \
|
||||
str = (char *)jump_table.SDL_malloc(len); \
|
||||
if (str) { \
|
||||
result = jump_table.SDL_vsnprintf(str, len, fmt, ap); \
|
||||
} \
|
||||
} \
|
||||
va_end(ap); \
|
||||
return jump_table.SDL_SetError("%s", buf); \
|
||||
if (result >= 0) { \
|
||||
result = jump_table.SDL_SetError("%s", str); \
|
||||
} \
|
||||
if (str != buf) { \
|
||||
jump_table.SDL_free(str); \
|
||||
} \
|
||||
return result; \
|
||||
} \
|
||||
_static int SDLCALL SDL_sscanf##name(const char *buf, SDL_SCANF_FORMAT_STRING const char *fmt, ...) { \
|
||||
int retval; va_list ap; initcall; va_start(ap, fmt); \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue