TTF_Render{Text|UTF8}_* memory leak when using non const strings

Hi,

I’m experiencing memory leak in my code (at the bottom).
If I replace TTF_RenderText_Blended(font, my_order , black) by
TTF_RenderText_Blended(font, “my_order” , black) the memory leak
disappears.
It disapears also if I replace it by
TTF_RenderUNICODE_Blended(font, (Uint16*)my_order , black)

for me it could be the unicode_text allocation in TTF_Render{Text|UTF8}_*

Do you have any other idea ?

Vincent–
char * order[4] = {
“Order by edition”,
“Order by genre”,
“Order by title”,
“Order by artist”,
};

void CScreenSongs::draw( void )
{
glColor4f(1.0,1.0,1.0,1.0);

    SDL_Color black = {0,0,0,0};

    TTF_Font *font = TTF_OpenFont("fonts/arial.ttf", 25);
    char * my_order;

    my_order =

order[CScreenManager::getSingletonPtr()->getSongs()->getOrder()];

    SDL_Surface * orderSurf = TTF_RenderText_Blended(font, my_order

, black);
//do stuffs (or do nothing)
SDL_FreeSurface(orderSurf);
TTF_CloseFont(font);
}

Ok,

I’ve tracked the bug, it’s a bug in the build process of freetype-2.1.10
https://bugs.gentoo.org/show_bug.cgi?id=150935
Where the definition of TT_CONFIG_OPTION_BYTECODE_INTERPRETER
in the CFLAGS leads to the memory leak (simple example in the bug report).
I’ve post it here cause it could also be a misuse of freetype in SDL_ttf

Vincent

Vincent Le Ligeour a ?crit :> Hi,

I’m experiencing memory leak in my code (at the bottom).
If I replace TTF_RenderText_Blended(font, my_order , black) by
TTF_RenderText_Blended(font, “my_order” , black) the memory leak
disappears.
It disapears also if I replace it by
TTF_RenderUNICODE_Blended(font, (Uint16*)my_order , black)

for me it could be the unicode_text allocation in TTF_Render{Text|UTF8}_*

Do you have any other idea ?

Vincent


char * order[4] = {
“Order by edition”,
“Order by genre”,
“Order by title”,
“Order by artist”,
};

void CScreenSongs::draw( void )
{
glColor4f(1.0,1.0,1.0,1.0);

    SDL_Color black = {0,0,0,0};

    TTF_Font *font = TTF_OpenFont("fonts/arial.ttf", 25);
    char * my_order;

    my_order =

order[CScreenManager::getSingletonPtr()->getSongs()->getOrder()];

    SDL_Surface * orderSurf = TTF_RenderText_Blended(font, my_order

, black);
//do stuffs (or do nothing)
SDL_FreeSurface(orderSurf);
TTF_CloseFont(font);
}


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl