mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-05-03 12:34:41 +00:00
Don't automatically free temporary memory, let the application call SDL_FreeTemporaryMemory() when it's ready.
Also mark up all functions that return temporary memory with SDL_DECLSPEC_TEMP, to help people implementing language bindings. Fixes https://github.com/libsdl-org/SDL/issues/10378
This commit is contained in:
@@ -233,32 +233,6 @@ static int events_temporaryMemory(void *arg)
|
||||
SDL_free(claimed);
|
||||
}
|
||||
|
||||
{
|
||||
/* Create event memory and queue it */
|
||||
mem = SDL_AllocateTemporaryMemory(1);
|
||||
SDLTest_AssertCheck(mem != NULL, "SDL_AllocateTemporaryMemory()");
|
||||
*(char *)mem = '3';
|
||||
|
||||
SDL_zero(event);
|
||||
event.type = SDL_EVENT_USER;
|
||||
event.user.data1 = mem;
|
||||
SDL_PushEvent(&event);
|
||||
|
||||
/* Get the event and verify the memory is valid */
|
||||
found = SDL_FALSE;
|
||||
while (SDL_PollEvent(&event)) {
|
||||
if (event.type == SDL_EVENT_USER && event.user.data1 == mem) {
|
||||
found = SDL_TRUE;
|
||||
}
|
||||
}
|
||||
SDLTest_AssertCheck(found, "SDL_PollEvent() returned queued event");
|
||||
|
||||
/* Verify that pumping the event loop frees event memory */
|
||||
SDL_PumpEvents();
|
||||
claimed = SDL_ClaimTemporaryMemory(mem);
|
||||
SDLTest_AssertCheck(claimed == NULL, "SDL_ClaimTemporaryMemory() can't claim memory after pumping the event loop");
|
||||
}
|
||||
|
||||
return TEST_COMPLETED;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user