Talk:SDL:Tutorials:Displaying a Bitmap from a Custom Resource File using SDL RWops
From GDWiki
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:
- a value of 1 as the second parameter. (Passing 1 means that we'd like SDL to automatically release the resource after it has been read. Better safe than sorry!)
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.

