Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In SDL do I need to free the surface if I re-render text?

Tags:

c

text

sdl

if I use the following code...

message = TTF_RenderText_Solid( font, "Lorem Ipsum", textColor ); 

Do I need to free message before I can do this

message = TTF_RenderText_Solid( font, "Lorem Ipsum part 2", textColor ); 

i.e. does it give me a new surface (and so I have to clean up the old one) or does it just blit over the old one?

like image 738
michael Avatar asked Oct 21 '25 13:10

michael


1 Answers

Yes, you should free message with SDL_FreeSurface when you're done with it. The returned SDL_Surface is allocated with SDL_AllocSurface() , and is not reused, so you'll leak if you don't free it in this case.

like image 57
nos Avatar answered Oct 23 '25 05:10

nos



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!