The real issue here is that SDL_DisplayFormat creates a
deep copy of the surface you passed.
In you original code:
Surface1 = TTF_RenderText_Solid(.......);Surface1 = SDL_DisplayFormat(Surface1);SDL_FreeSurface(Surface1);
Surface1 points to a surface that is created by TTF_RenderText_Solid. Then when SDL_DisplayFormat is called, Surface1 points to a new surface created by the call. The pointer top the original surface is lost. Your second snippet solves this problem by freeing both.
Your last snippet:
Temp = TTF_RenderText_Solid(.......);Surface1 = SDL_DisplayFormat(Temp);Temp = TTF_RenderText_Solid(.......);Surface2 = SDL_DisplayFormat(Temp);SDL_FreeSurface(Surface1);SDL_FreeSurface(Surface2);SDL_FreeSurface(Temp);
Creates a memory leak because the surface Temp points to after the first call is never freed. When the next call to TTF_RenderText_Solid is made, you lose the original pointer.
I would suggest using a utility function for this:
SDL_Surface* RenderText(......){ SDL_Surface* temp = TTF_RenderText_Solid(.......); SDL_Surface* text = SDL_DisplayFormat(Temp); SDL_FreeSurface(temp); return text;}
Just be sure that you eventually call SDL_FreeSurface on the surfaces returned by this function.
Hope that made sense.