mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-06-06 06:34:35 +00:00
error: SDL's allocators now call SDL_OutOfMemory on error.
This means the allocator's caller doesn't need to use SDL_OutOfMemory directly if the allocation fails. This applies to the usual allocators: SDL_malloc, SDL_calloc, SDL_realloc (all of these regardless of if the app supplied a custom allocator or we're using system malloc() or an internal copy of dlmalloc under the hood), SDL_aligned_alloc, SDL_small_alloc, SDL_strdup, SDL_asprintf, SDL_wcsdup... probably others. If it returns something you can pass to SDL_free, it should work. The caller might still need to use SDL_OutOfMemory if something that wasn't SDL allocated the memory: operator new in C++ code, Objective-C's alloc message, win32 GlobalAlloc, etc. Fixes #8642.
This commit is contained in:
parent
70b65d4170
commit
447b508a77
197 changed files with 313 additions and 742 deletions
|
|
@ -36,7 +36,6 @@ GetNearbyFilename(const char *file)
|
|||
|
||||
if (!path) {
|
||||
SDL_free(base);
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -53,11 +52,7 @@ GetNearbyFilename(const char *file)
|
|||
SDL_free(path);
|
||||
}
|
||||
|
||||
path = SDL_strdup(file);
|
||||
if (!path) {
|
||||
SDL_OutOfMemory();
|
||||
}
|
||||
return path;
|
||||
return SDL_strdup(file);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -73,16 +68,9 @@ char *
|
|||
GetResourceFilename(const char *user_specified, const char *def)
|
||||
{
|
||||
if (user_specified) {
|
||||
char *ret = SDL_strdup(user_specified);
|
||||
|
||||
if (!ret) {
|
||||
SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
return ret;
|
||||
} else {
|
||||
return GetNearbyFilename(def);
|
||||
return SDL_strdup(user_specified);
|
||||
}
|
||||
return GetNearbyFilename(def);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue