123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809 |
- /*
- Simple DirectMedia Layer
- Copyright (C) 1997-2025 Sam Lantinga <[email protected]>
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
- */
- #include "SDL_internal.h"
- #include "SDL_hints_c.h"
- #include "SDL_properties_c.h"
- typedef struct
- {
- SDL_PropertyType type;
- union {
- void *pointer_value;
- char *string_value;
- Sint64 number_value;
- float float_value;
- bool boolean_value;
- } value;
- char *string_storage;
- SDL_CleanupPropertyCallback cleanup;
- void *userdata;
- } SDL_Property;
- typedef struct
- {
- SDL_HashTable *props;
- SDL_Mutex *lock;
- } SDL_Properties;
- static SDL_InitState SDL_properties_init;
- static SDL_HashTable *SDL_properties;
- static SDL_AtomicU32 SDL_last_properties_id;
- static SDL_AtomicU32 SDL_global_properties;
- static void SDL_FreePropertyWithCleanup(const void *key, const void *value, void *data, bool cleanup)
- {
- SDL_Property *property = (SDL_Property *)value;
- if (property) {
- switch (property->type) {
- case SDL_PROPERTY_TYPE_POINTER:
- if (property->cleanup && cleanup) {
- property->cleanup(property->userdata, property->value.pointer_value);
- }
- break;
- case SDL_PROPERTY_TYPE_STRING:
- SDL_free(property->value.string_value);
- break;
- default:
- break;
- }
- SDL_free(property->string_storage);
- }
- SDL_free((void *)key);
- SDL_free((void *)value);
- }
- static void SDL_FreeProperty(const void *key, const void *value, void *data)
- {
- SDL_FreePropertyWithCleanup(key, value, data, true);
- }
- static void SDL_FreeProperties(SDL_Properties *properties)
- {
- if (properties) {
- if (properties->props) {
- SDL_DestroyHashTable(properties->props);
- properties->props = NULL;
- }
- if (properties->lock) {
- SDL_DestroyMutex(properties->lock);
- properties->lock = NULL;
- }
- SDL_free(properties);
- }
- }
- bool SDL_InitProperties(void)
- {
- if (!SDL_ShouldInit(&SDL_properties_init)) {
- return true;
- }
- SDL_properties = SDL_CreateHashTable(NULL, 16, SDL_HashID, SDL_KeyMatchID, NULL, true, false);
- if (!SDL_properties) {
- goto error;
- }
- SDL_SetInitialized(&SDL_properties_init, true);
- return true;
- error:
- SDL_SetInitialized(&SDL_properties_init, true);
- SDL_QuitProperties();
- return false;
- }
- void SDL_QuitProperties(void)
- {
- if (!SDL_ShouldQuit(&SDL_properties_init)) {
- return;
- }
- SDL_PropertiesID props;
- do {
- props = SDL_GetAtomicU32(&SDL_global_properties);
- } while (!SDL_CompareAndSwapAtomicU32(&SDL_global_properties, props, 0));
- if (props) {
- SDL_DestroyProperties(props);
- }
- if (SDL_properties) {
- void *iter;
- const void *key, *value;
- iter = NULL;
- while (SDL_IterateHashTable(SDL_properties, &key, &value, &iter)) {
- SDL_FreeProperties((SDL_Properties *)value);
- }
- SDL_DestroyHashTable(SDL_properties);
- SDL_properties = NULL;
- }
- SDL_SetInitialized(&SDL_properties_init, false);
- }
- static bool SDL_CheckInitProperties(void)
- {
- return SDL_InitProperties();
- }
- SDL_PropertiesID SDL_GetGlobalProperties(void)
- {
- SDL_PropertiesID props = SDL_GetAtomicU32(&SDL_global_properties);
- if (!props) {
- props = SDL_CreateProperties();
- if (!SDL_CompareAndSwapAtomicU32(&SDL_global_properties, 0, props)) {
- // Somebody else created global properties before us, just use those
- SDL_DestroyProperties(props);
- props = SDL_GetAtomicU32(&SDL_global_properties);
- }
- }
- return props;
- }
- SDL_PropertiesID SDL_CreateProperties(void)
- {
- SDL_PropertiesID props = 0;
- SDL_Properties *properties = NULL;
- bool inserted = false;
- if (!SDL_CheckInitProperties()) {
- return 0;
- }
- properties = (SDL_Properties *)SDL_calloc(1, sizeof(*properties));
- if (!properties) {
- goto error;
- }
- properties->props = SDL_CreateHashTable(NULL, 4, SDL_HashString, SDL_KeyMatchString, SDL_FreeProperty, false, false);
- if (!properties->props) {
- goto error;
- }
- // If this fails we'll continue without it.
- properties->lock = SDL_CreateMutex();
- for ( ; ; ) {
- props = (SDL_GetAtomicU32(&SDL_last_properties_id) + 1);
- if (props == 0) {
- continue;
- }
- if (SDL_CompareAndSwapAtomicU32(&SDL_last_properties_id, props - 1, props)) {
- break;
- }
- }
- if (SDL_InsertIntoHashTable(SDL_properties, (const void *)(uintptr_t)props, properties)) {
- inserted = true;
- }
- if (inserted) {
- // All done!
- return props;
- }
- error:
- SDL_FreeProperties(properties);
- return 0;
- }
- bool SDL_CopyProperties(SDL_PropertiesID src, SDL_PropertiesID dst)
- {
- SDL_Properties *src_properties = NULL;
- SDL_Properties *dst_properties = NULL;
- bool result = true;
- if (!src) {
- return SDL_InvalidParamError("src");
- }
- if (!dst) {
- return SDL_InvalidParamError("dst");
- }
- SDL_FindInHashTable(SDL_properties, (const void *)(uintptr_t)src, (const void **)&src_properties);
- SDL_FindInHashTable(SDL_properties, (const void *)(uintptr_t)dst, (const void **)&dst_properties);
- if (!src_properties) {
- return SDL_InvalidParamError("src");
- }
- if (!dst_properties) {
- return SDL_InvalidParamError("dst");
- }
- SDL_LockMutex(src_properties->lock);
- SDL_LockMutex(dst_properties->lock);
- {
- void *iter;
- const void *key, *value;
- iter = NULL;
- while (SDL_IterateHashTable(src_properties->props, &key, &value, &iter)) {
- const char *src_name = (const char *)key;
- const SDL_Property *src_property = (const SDL_Property *)value;
- char *dst_name;
- SDL_Property *dst_property;
- if (src_property->cleanup) {
- // Can't copy properties with cleanup functions, we don't know how to duplicate the data
- continue;
- }
- SDL_RemoveFromHashTable(dst_properties->props, src_name);
- dst_name = SDL_strdup(src_name);
- if (!dst_name) {
- result = false;
- continue;
- }
- dst_property = (SDL_Property *)SDL_malloc(sizeof(*dst_property));
- if (!dst_property) {
- SDL_free(dst_name);
- result = false;
- continue;
- }
- SDL_copyp(dst_property, src_property);
- if (src_property->type == SDL_PROPERTY_TYPE_STRING) {
- dst_property->value.string_value = SDL_strdup(src_property->value.string_value);
- }
- if (!SDL_InsertIntoHashTable(dst_properties->props, dst_name, dst_property)) {
- SDL_FreePropertyWithCleanup(dst_name, dst_property, NULL, false);
- result = false;
- }
- }
- }
- SDL_UnlockMutex(dst_properties->lock);
- SDL_UnlockMutex(src_properties->lock);
- return result;
- }
- bool SDL_LockProperties(SDL_PropertiesID props)
- {
- SDL_Properties *properties = NULL;
- if (!props) {
- return SDL_InvalidParamError("props");
- }
- SDL_FindInHashTable(SDL_properties, (const void *)(uintptr_t)props, (const void **)&properties);
- if (!properties) {
- return SDL_InvalidParamError("props");
- }
- SDL_LockMutex(properties->lock);
- return true;
- }
- void SDL_UnlockProperties(SDL_PropertiesID props)
- {
- SDL_Properties *properties = NULL;
- if (!props) {
- return;
- }
- SDL_FindInHashTable(SDL_properties, (const void *)(uintptr_t)props, (const void **)&properties);
- if (!properties) {
- return;
- }
- SDL_UnlockMutex(properties->lock);
- }
- static bool SDL_PrivateSetProperty(SDL_PropertiesID props, const char *name, SDL_Property *property)
- {
- SDL_Properties *properties = NULL;
- bool result = true;
- if (!props) {
- SDL_FreePropertyWithCleanup(NULL, property, NULL, true);
- return SDL_InvalidParamError("props");
- }
- if (!name || !*name) {
- SDL_FreePropertyWithCleanup(NULL, property, NULL, true);
- return SDL_InvalidParamError("name");
- }
- SDL_FindInHashTable(SDL_properties, (const void *)(uintptr_t)props, (const void **)&properties);
- if (!properties) {
- SDL_FreePropertyWithCleanup(NULL, property, NULL, true);
- return SDL_InvalidParamError("props");
- }
- SDL_LockMutex(properties->lock);
- {
- SDL_RemoveFromHashTable(properties->props, name);
- if (property) {
- char *key = SDL_strdup(name);
- if (!SDL_InsertIntoHashTable(properties->props, key, property)) {
- SDL_FreePropertyWithCleanup(key, property, NULL, true);
- result = false;
- }
- }
- }
- SDL_UnlockMutex(properties->lock);
- return result;
- }
- bool SDL_SetPointerPropertyWithCleanup(SDL_PropertiesID props, const char *name, void *value, SDL_CleanupPropertyCallback cleanup, void *userdata)
- {
- SDL_Property *property;
- if (!value) {
- if (cleanup) {
- cleanup(userdata, value);
- }
- return SDL_ClearProperty(props, name);
- }
- property = (SDL_Property *)SDL_calloc(1, sizeof(*property));
- if (!property) {
- if (cleanup) {
- cleanup(userdata, value);
- }
- SDL_FreePropertyWithCleanup(NULL, property, NULL, false);
- return false;
- }
- property->type = SDL_PROPERTY_TYPE_POINTER;
- property->value.pointer_value = value;
- property->cleanup = cleanup;
- property->userdata = userdata;
- return SDL_PrivateSetProperty(props, name, property);
- }
- bool SDL_SetPointerProperty(SDL_PropertiesID props, const char *name, void *value)
- {
- SDL_Property *property;
- if (!value) {
- return SDL_ClearProperty(props, name);
- }
- property = (SDL_Property *)SDL_calloc(1, sizeof(*property));
- if (!property) {
- return false;
- }
- property->type = SDL_PROPERTY_TYPE_POINTER;
- property->value.pointer_value = value;
- return SDL_PrivateSetProperty(props, name, property);
- }
- static void SDLCALL CleanupFreeableProperty(void *userdata, void *value)
- {
- SDL_free(value);
- }
- bool SDL_SetFreeableProperty(SDL_PropertiesID props, const char *name, void *value)
- {
- return SDL_SetPointerPropertyWithCleanup(props, name, value, CleanupFreeableProperty, NULL);
- }
- static void SDLCALL CleanupSurface(void *userdata, void *value)
- {
- SDL_Surface *surface = (SDL_Surface *)value;
- SDL_DestroySurface(surface);
- }
- bool SDL_SetSurfaceProperty(SDL_PropertiesID props, const char *name, SDL_Surface *surface)
- {
- return SDL_SetPointerPropertyWithCleanup(props, name, surface, CleanupSurface, NULL);
- }
- bool SDL_SetStringProperty(SDL_PropertiesID props, const char *name, const char *value)
- {
- SDL_Property *property;
- if (!value) {
- return SDL_ClearProperty(props, name);
- }
- property = (SDL_Property *)SDL_calloc(1, sizeof(*property));
- if (!property) {
- return false;
- }
- property->type = SDL_PROPERTY_TYPE_STRING;
- property->value.string_value = SDL_strdup(value);
- if (!property->value.string_value) {
- SDL_free(property);
- return false;
- }
- return SDL_PrivateSetProperty(props, name, property);
- }
- bool SDL_SetNumberProperty(SDL_PropertiesID props, const char *name, Sint64 value)
- {
- SDL_Property *property = (SDL_Property *)SDL_calloc(1, sizeof(*property));
- if (!property) {
- return false;
- }
- property->type = SDL_PROPERTY_TYPE_NUMBER;
- property->value.number_value = value;
- return SDL_PrivateSetProperty(props, name, property);
- }
- bool SDL_SetFloatProperty(SDL_PropertiesID props, const char *name, float value)
- {
- SDL_Property *property = (SDL_Property *)SDL_calloc(1, sizeof(*property));
- if (!property) {
- return false;
- }
- property->type = SDL_PROPERTY_TYPE_FLOAT;
- property->value.float_value = value;
- return SDL_PrivateSetProperty(props, name, property);
- }
- bool SDL_SetBooleanProperty(SDL_PropertiesID props, const char *name, bool value)
- {
- SDL_Property *property = (SDL_Property *)SDL_calloc(1, sizeof(*property));
- if (!property) {
- return false;
- }
- property->type = SDL_PROPERTY_TYPE_BOOLEAN;
- property->value.boolean_value = value ? true : false;
- return SDL_PrivateSetProperty(props, name, property);
- }
- bool SDL_HasProperty(SDL_PropertiesID props, const char *name)
- {
- return (SDL_GetPropertyType(props, name) != SDL_PROPERTY_TYPE_INVALID);
- }
- SDL_PropertyType SDL_GetPropertyType(SDL_PropertiesID props, const char *name)
- {
- SDL_Properties *properties = NULL;
- SDL_PropertyType type = SDL_PROPERTY_TYPE_INVALID;
- if (!props) {
- return SDL_PROPERTY_TYPE_INVALID;
- }
- if (!name || !*name) {
- return SDL_PROPERTY_TYPE_INVALID;
- }
- SDL_FindInHashTable(SDL_properties, (const void *)(uintptr_t)props, (const void **)&properties);
- if (!properties) {
- return SDL_PROPERTY_TYPE_INVALID;
- }
- SDL_LockMutex(properties->lock);
- {
- SDL_Property *property = NULL;
- if (SDL_FindInHashTable(properties->props, name, (const void **)&property)) {
- type = property->type;
- }
- }
- SDL_UnlockMutex(properties->lock);
- return type;
- }
- void *SDL_GetPointerProperty(SDL_PropertiesID props, const char *name, void *default_value)
- {
- SDL_Properties *properties = NULL;
- void *value = default_value;
- if (!props) {
- return value;
- }
- if (!name || !*name) {
- return value;
- }
- SDL_FindInHashTable(SDL_properties, (const void *)(uintptr_t)props, (const void **)&properties);
- if (!properties) {
- return value;
- }
- /* Note that taking the lock here only guarantees that we won't read the
- * hashtable while it's being modified. The value itself can easily be
- * freed from another thread after it is returned here.
- */
- SDL_LockMutex(properties->lock);
- {
- SDL_Property *property = NULL;
- if (SDL_FindInHashTable(properties->props, name, (const void **)&property)) {
- if (property->type == SDL_PROPERTY_TYPE_POINTER) {
- value = property->value.pointer_value;
- }
- }
- }
- SDL_UnlockMutex(properties->lock);
- return value;
- }
- const char *SDL_GetStringProperty(SDL_PropertiesID props, const char *name, const char *default_value)
- {
- SDL_Properties *properties = NULL;
- const char *value = default_value;
- if (!props) {
- return value;
- }
- if (!name || !*name) {
- return value;
- }
- SDL_FindInHashTable(SDL_properties, (const void *)(uintptr_t)props, (const void **)&properties);
- if (!properties) {
- return value;
- }
- SDL_LockMutex(properties->lock);
- {
- SDL_Property *property = NULL;
- if (SDL_FindInHashTable(properties->props, name, (const void **)&property)) {
- switch (property->type) {
- case SDL_PROPERTY_TYPE_STRING:
- value = property->value.string_value;
- break;
- case SDL_PROPERTY_TYPE_NUMBER:
- if (property->string_storage) {
- value = property->string_storage;
- } else {
- SDL_asprintf(&property->string_storage, "%" SDL_PRIs64, property->value.number_value);
- if (property->string_storage) {
- value = property->string_storage;
- }
- }
- break;
- case SDL_PROPERTY_TYPE_FLOAT:
- if (property->string_storage) {
- value = property->string_storage;
- } else {
- SDL_asprintf(&property->string_storage, "%f", property->value.float_value);
- if (property->string_storage) {
- value = property->string_storage;
- }
- }
- break;
- case SDL_PROPERTY_TYPE_BOOLEAN:
- value = property->value.boolean_value ? "true" : "false";
- break;
- default:
- break;
- }
- }
- }
- SDL_UnlockMutex(properties->lock);
- return value;
- }
- Sint64 SDL_GetNumberProperty(SDL_PropertiesID props, const char *name, Sint64 default_value)
- {
- SDL_Properties *properties = NULL;
- Sint64 value = default_value;
- if (!props) {
- return value;
- }
- if (!name || !*name) {
- return value;
- }
- SDL_FindInHashTable(SDL_properties, (const void *)(uintptr_t)props, (const void **)&properties);
- if (!properties) {
- return value;
- }
- SDL_LockMutex(properties->lock);
- {
- SDL_Property *property = NULL;
- if (SDL_FindInHashTable(properties->props, name, (const void **)&property)) {
- switch (property->type) {
- case SDL_PROPERTY_TYPE_STRING:
- value = (Sint64)SDL_strtoll(property->value.string_value, NULL, 0);
- break;
- case SDL_PROPERTY_TYPE_NUMBER:
- value = property->value.number_value;
- break;
- case SDL_PROPERTY_TYPE_FLOAT:
- value = (Sint64)SDL_round((double)property->value.float_value);
- break;
- case SDL_PROPERTY_TYPE_BOOLEAN:
- value = property->value.boolean_value;
- break;
- default:
- break;
- }
- }
- }
- SDL_UnlockMutex(properties->lock);
- return value;
- }
- float SDL_GetFloatProperty(SDL_PropertiesID props, const char *name, float default_value)
- {
- SDL_Properties *properties = NULL;
- float value = default_value;
- if (!props) {
- return value;
- }
- if (!name || !*name) {
- return value;
- }
- SDL_FindInHashTable(SDL_properties, (const void *)(uintptr_t)props, (const void **)&properties);
- if (!properties) {
- return value;
- }
- SDL_LockMutex(properties->lock);
- {
- SDL_Property *property = NULL;
- if (SDL_FindInHashTable(properties->props, name, (const void **)&property)) {
- switch (property->type) {
- case SDL_PROPERTY_TYPE_STRING:
- value = (float)SDL_atof(property->value.string_value);
- break;
- case SDL_PROPERTY_TYPE_NUMBER:
- value = (float)property->value.number_value;
- break;
- case SDL_PROPERTY_TYPE_FLOAT:
- value = property->value.float_value;
- break;
- case SDL_PROPERTY_TYPE_BOOLEAN:
- value = (float)property->value.boolean_value;
- break;
- default:
- break;
- }
- }
- }
- SDL_UnlockMutex(properties->lock);
- return value;
- }
- bool SDL_GetBooleanProperty(SDL_PropertiesID props, const char *name, bool default_value)
- {
- SDL_Properties *properties = NULL;
- bool value = default_value ? true : false;
- if (!props) {
- return value;
- }
- if (!name || !*name) {
- return value;
- }
- SDL_FindInHashTable(SDL_properties, (const void *)(uintptr_t)props, (const void **)&properties);
- if (!properties) {
- return value;
- }
- SDL_LockMutex(properties->lock);
- {
- SDL_Property *property = NULL;
- if (SDL_FindInHashTable(properties->props, name, (const void **)&property)) {
- switch (property->type) {
- case SDL_PROPERTY_TYPE_STRING:
- value = SDL_GetStringBoolean(property->value.string_value, default_value);
- break;
- case SDL_PROPERTY_TYPE_NUMBER:
- value = (property->value.number_value != 0);
- break;
- case SDL_PROPERTY_TYPE_FLOAT:
- value = (property->value.float_value != 0.0f);
- break;
- case SDL_PROPERTY_TYPE_BOOLEAN:
- value = property->value.boolean_value;
- break;
- default:
- break;
- }
- }
- }
- SDL_UnlockMutex(properties->lock);
- return value;
- }
- bool SDL_ClearProperty(SDL_PropertiesID props, const char *name)
- {
- return SDL_PrivateSetProperty(props, name, NULL);
- }
- bool SDL_EnumerateProperties(SDL_PropertiesID props, SDL_EnumeratePropertiesCallback callback, void *userdata)
- {
- SDL_Properties *properties = NULL;
- if (!props) {
- return SDL_InvalidParamError("props");
- }
- if (!callback) {
- return SDL_InvalidParamError("callback");
- }
- SDL_FindInHashTable(SDL_properties, (const void *)(uintptr_t)props, (const void **)&properties);
- if (!properties) {
- return SDL_InvalidParamError("props");
- }
- SDL_LockMutex(properties->lock);
- {
- void *iter;
- const void *key, *value;
- iter = NULL;
- while (SDL_IterateHashTable(properties->props, &key, &value, &iter)) {
- callback(userdata, props, (const char *)key);
- }
- }
- SDL_UnlockMutex(properties->lock);
- return true;
- }
- static void SDLCALL SDL_DumpPropertiesCallback(void *userdata, SDL_PropertiesID props, const char *name)
- {
- switch (SDL_GetPropertyType(props, name)) {
- case SDL_PROPERTY_TYPE_POINTER:
- SDL_Log("%s: %p\n", name, SDL_GetPointerProperty(props, name, NULL));
- break;
- case SDL_PROPERTY_TYPE_STRING:
- SDL_Log("%s: \"%s\"\n", name, SDL_GetStringProperty(props, name, ""));
- break;
- case SDL_PROPERTY_TYPE_NUMBER:
- {
- Sint64 value = SDL_GetNumberProperty(props, name, 0);
- SDL_Log("%s: %" SDL_PRIs64 " (%" SDL_PRIx64 ")\n", name, value, value);
- }
- break;
- case SDL_PROPERTY_TYPE_FLOAT:
- SDL_Log("%s: %g\n", name, SDL_GetFloatProperty(props, name, 0.0f));
- break;
- case SDL_PROPERTY_TYPE_BOOLEAN:
- SDL_Log("%s: %s\n", name, SDL_GetBooleanProperty(props, name, false) ? "true" : "false");
- break;
- default:
- SDL_Log("%s UNKNOWN TYPE\n", name);
- break;
- }
- }
- bool SDL_DumpProperties(SDL_PropertiesID props)
- {
- return SDL_EnumerateProperties(props, SDL_DumpPropertiesCallback, NULL);
- }
- void SDL_DestroyProperties(SDL_PropertiesID props)
- {
- SDL_Properties *properties = NULL;
- if (!props) {
- return;
- }
- if (SDL_FindInHashTable(SDL_properties, (const void *)(uintptr_t)props, (const void **)&properties)) {
- SDL_FreeProperties(properties);
- SDL_RemoveFromHashTable(SDL_properties, (const void *)(uintptr_t)props);
- }
- }
|