[SDL] Memory leak in SDL_putenv() - can it be plugged safely?
Doug
biteme at bitbasher.net
Wed Jun 13 01:53:20 PDT 2007
In article <E1HyMao-00075D-IY at seras.devolution.com>, OurFavoritePirate :P
says...
>>
>> Is there any reason why SDL can't free SDL_envmem on a call to
>> SDL_Quit()? Are there existing apps that would expect the environment
>> to be persistent after SDL_Quit() is called?
>
>Yes, some apps set environment variables before SDL_Init(), to affect
>initialization, and then during execution call SDL_Quit() / SDL_Init()
>to re-initialize. This isn't an especially good practice, but at this
>point it's not something I want to break gratuitiously in SDL 1.2.
>
>Feel free to plug it in your copy though. :)
My atexit() senses are tingling. If I plug this in my copy, I'm tempted to
free SDL_envmem in a registered atexit() handler. Since atexit() should never
be called directly by an app, it should survive the SDL_putenv(), SDL_Init(),
SDL_Quit(), SDL_Init() cycle.
I'm not sure if having SDL depend on atexit() would work on all platforms, but
if I use this plug in my copy I can solve my problem without breaking need to
have SDL_envmem persistent across quit/init cycles.
Since my CRT memory leak code "goes off" in the destructor of a static class,
I'm pretty sure said destructor is called AFTER all atexit() handlers.
Thanks,
Doug.
More information about the SDL
mailing list