Talk:SDL:Tutorials:Displaying a Bitmap from a Custom Resource File using SDL RWops
From GPWiki
The wiki is now hosted by GameDev.NET at wiki.gamedev.net. All gpwiki.org content has been moved to the new server. However, the GPWiki forums are still active! Come say hello. This code doesn't work for me when the resource file has 7 or more files :( gdb says the error it's at line "filename = (char *) malloc(filenamesize + 1);" I think the second parameter to SDL_LoadBMP_RW(rw, 1); is non obvious and needs more justification. At the time of reading the article says:
The resource, does this mean rw, buffer or rw and buffer? Looking at the code it looks like you expect it to free just rw. Reading the SDL documentation I think it frees just buffer, requiring you to call SDL_RWclose() or SDL_FreeRW() at some point. I think that the line. int *filestart = (int *) malloc(numfiles); should reserve (sizeof(int) * numfiles) as it is a pointer to int, this way: int *filestart = (int *) malloc(sizeof(int) * numfiles); i haven't analised the code but otherwise it provocates segmentation faults. I changed the code in the web, but not the zip, probably it is still wrong. |


