Made event and temporary string memory thread-local and added SDL_FreeEventMemory()
Fixes https://github.com/libsdl-org/SDL/issues/10283
This commit is contained in:
@@ -1407,7 +1407,7 @@ extern SDL_DECLSPEC SDL_bool SDLCALL SDL_EventEnabled(Uint32 type);
|
||||
extern SDL_DECLSPEC Uint32 SDLCALL SDL_RegisterEvents(int numevents);
|
||||
|
||||
/**
|
||||
* Allocate dynamic memory for an SDL event.
|
||||
* Allocate temporary memory for an SDL event.
|
||||
*
|
||||
* You can use this to allocate memory for user events that will be
|
||||
* automatically freed after the event is processed.
|
||||
@@ -1419,9 +1419,26 @@ extern SDL_DECLSPEC Uint32 SDLCALL SDL_RegisterEvents(int numevents);
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_FreeEventMemory
|
||||
*/
|
||||
extern SDL_DECLSPEC void * SDLCALL SDL_AllocateEventMemory(size_t size);
|
||||
|
||||
/**
|
||||
* Free temporary event memory allocated by SDL.
|
||||
*
|
||||
* This function frees temporary memory allocated for events and APIs that return temporary strings. This memory is local to the thread that creates it and is automatically freed for the main thread when pumping the event loop. For other threads you may want to call this function periodically to free any temporary memory created by that thread.
|
||||
*
|
||||
* Note that if you call SDL_AllocateEventMemory() on one thread and pass it to another thread, e.g. via a user event, then you should be sure the other thread has finished processing it before calling this function.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_AllocateEventMemory
|
||||
*/
|
||||
extern SDL_DECLSPEC void SDLCALL SDL_FreeEventMemory(void);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user