Every time you call Draw
, you create a new texture in tex
without freeing the previous one.
Your destructor is also wrong... free
is only for memory allocated with malloc
(or calloc
or realloc
). As you are not using malloc
anywhere, you really have no business using free
.
- I don't think
mfont
is valid at this point (you're freeing it inDraw()
. tex
should be freed withSDL_DestroyTexture
.message
also should be freed bySDL_FreeSurface
.
I think the short answer is that you just need to read, understand, and follow the documentation for the APIs you are trying to use.