Consider the following C++ function:
SDL_Surface* loadBMP(std::string path, SDL_Surface* loadedBMP){
//Load bitmap
SDL_Surface* loadedBMP = SDL_LoadBMP(path);
if (loadedBMP == NULL){
printf("Unable to load image %s! SDL Error: %s\n", path.c_str(), SDL_GetError());
}
return loadedBMP;
//Magic
SDL_FreeSurface(loadedBMP);
}
Now, for the sake of this question, assume that loadedBMP
is a previously declared global variable.
Here is my question:
Is there a way to let a function continue running after a return
statement? In terms of this function, is there a way to have the final line, SDL_FreeSurface(loadedBMP)
, run after return
ing loadedBMP
?