mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-10-17 15:21:43 +00:00
Removed temporary memory from the API
It was intended to make the API easier to use, but various automatic garbage collection all had flaws, and making the application periodically clean up temporary memory added cognitive load to using the API, and in many cases was it was difficult to restructure threaded code to handle this. So, we're largely going back to the original system, where the API returns allocated results and you free them. In addition, to solve the problems we originally wanted temporary memory for: * Short strings with a finite count, like device names, get stored in a per-thread string pool. * Events continue to use temporary memory internally, which is cleaned up on the next event processing cycle.
This commit is contained in:
@@ -353,7 +353,7 @@ static int GlobStorageDirectoryEnumerator(const char *path, SDL_EnumerateDirecto
|
||||
return SDL_EnumerateStorageDirectory((SDL_Storage *) userdata, path, cb, cbuserdata);
|
||||
}
|
||||
|
||||
const char * const *SDL_GlobStorageDirectory(SDL_Storage *storage, const char *path, const char *pattern, SDL_GlobFlags flags, int *count)
|
||||
char **SDL_GlobStorageDirectory(SDL_Storage *storage, const char *path, const char *pattern, SDL_GlobFlags flags, int *count)
|
||||
{
|
||||
CHECK_STORAGE_MAGIC_RET(NULL)
|
||||
return SDL_InternalGlobDirectory(path, pattern, flags, count, GlobStorageDirectoryEnumerator, GlobStorageDirectoryGetPathInfo, storage);
|
||||
|
@@ -203,10 +203,8 @@ static SDL_Storage *GENERIC_Title_Create(const char *override, SDL_PropertiesID
|
||||
if (override != NULL) {
|
||||
basepath = SDL_strdup(override);
|
||||
} else {
|
||||
const char *sdlbasepath = SDL_GetBasePath();
|
||||
if (sdlbasepath) {
|
||||
basepath = SDL_strdup(sdlbasepath);
|
||||
}
|
||||
const char *base = SDL_GetBasePath();
|
||||
basepath = base ? SDL_strdup(base) : NULL;
|
||||
}
|
||||
|
||||
if (basepath != NULL) {
|
||||
@@ -242,11 +240,7 @@ static const SDL_StorageInterface GENERIC_user_iface = {
|
||||
static SDL_Storage *GENERIC_User_Create(const char *org, const char *app, SDL_PropertiesID props)
|
||||
{
|
||||
SDL_Storage *result;
|
||||
char *prefpath = NULL;
|
||||
const char *sdlprefpath = SDL_GetPrefPath(org, app);
|
||||
if (sdlprefpath) {
|
||||
prefpath = SDL_strdup(sdlprefpath);
|
||||
}
|
||||
char *prefpath = SDL_GetPrefPath(org, app);
|
||||
if (prefpath == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
Reference in New Issue
Block a user