I'd like to know how can I connect SDL_Surface* with shared_ptr?
I need to call SDL_FreeSurface(SDL_Surface*)
before I delete SDL_Surface
. How can I "modify deletion process" in shared_ptr?
Just pass SDL_FreeSurface to the constructor:
std::shared_ptr<SDL_Surface> shared_surf(SDL_LoadBMP("foo.bmp"), SDL_FreeSurface);
Just be sure you don't do this with the pointer returned by SDL_SetVideoMode
or SDL_GetVideoSurface
.