I hope I can explain this properly, but I have noticed an issue with the RWops function TTF_OpenFontRW, and that error can only be explained as follows :
I have created a routine that writes and reads all images, sounds and fonts into my own custom built resource file. When loading these resources again from my resource file, I use RWops. So, before using RWops I create a buffer in memory like this :
char Buffer = (char)malloc(Size);**
This allocates a block of memory, with the size according to the resource I want to load.
Then I use RWops to load this buffer into the RWops struct :
SDL_RWops RW = SDL_RWFromMem(Buffer, Size);*
Now I use individual RWops calls to load the appropriate resource and point to it :
Fonts : TTF_Font fnt = TTF_OpenFontRW(RW, 1, Size);
Images : SDL_Surface img = SDL_LoadBMP_RW(RW, 1);
Sounds : Mix_Chunk* snd = Mix_LoadWAV_RW(RW, 1);**
Having specified the “1” as an argument, I know these RW structs will release from memory automatically, so thats ok. Note : These are not all called at once, I have only written them together to show examples.
Now I can call free(Buffer) and this will free the memory chunk, and later when I’m done with the resource I call either _**SDL_FreeSurface() or TTF_CloseFont() or Mix_FreeChunk() **_etc…
For the TTF version, when I call free(Buffer) before _**TTF_CloseFont(), **_the buffer is freed and it also releases the memory that TTF’s fnt pointer is pointing to. With the other 2 resources this isn’t the case, so I am guessing it’s an issue with TTF_OpenFontRW.
This may sound terribly confusing, but if you do grasp it and have an idea, please let me know or better yet, if you coded any parts of _**TTF_OpenFontRW() **_then I might have spotted an error!