the_surface = SDL_DisplayFormatAlpha(the_surface);
That will cause memory to be lost. It is unrecoverable - a memleak! Everybody's favorite!
So ya, you're going to have to do something like this:
SDL_Surface *the_surface = null;
SDL_Surface *temp_surface = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, NPP, 0,0,0,0);
the_surface = SDL_DisplayFormatAlpha(temp_surface);
SDL_FreeSurface(temp_surface); //Free this.
Ya, I would have much rather preffered removing the temp_surface from that and having the SDL_CreateRGBSurface apply for the_surface, but it don't work! Like I said at the start of this post,
the_surface = SDL_DisplayFormatAlpha(the_surface);
memory leaks.