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:
Sam Lantinga
2024-07-26 18:57:18 -07:00
parent 21411c6418
commit 4f55271571
100 changed files with 737 additions and 853 deletions

View File

@@ -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);

View File

@@ -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;
}