I got this function that make my program crash

252 views Asked by At

I am trying to make a text box so i made this function to show text on screen,

i have a fps regulator, so the function is called 33 times a second.

I have an old computer (64 mb video ram and 1 ram + Pentium 4 CPU 2.8GHz)

when i remove this function from my code it never freeze, why?

MESSAGE (SDL_Surface *MESSAGE = NULL;) is declared at the top of my code under the include lines. ( So is SCREEN)

void text_box()
{
    MESSAGE = TTF_RenderText_Solid( font,  "Ligne #1" , noir ); 
    apply_surface( 2, 503, MESSAGE, SCREEN );   
    SDL_FreeSurface(MESSAGE);                 

    MESSAGE = TTF_RenderText_Solid( font,  "Ligne #2" , noir );
    apply_surface( 2, 510, MESSAGE, SCREEN );
    SDL_FreeSurface(MESSAGE);

    MESSAGE = TTF_RenderText_Solid( font,  "Ligne #3" , noir );
    apply_surface( 2, 517, MESSAGE, SCREEN );
    SDL_FreeSurface(MESSAGE);

    MESSAGE = TTF_RenderText_Solid( font,  "Ligne #4" , noir );
    apply_surface( 2, 524, MESSAGE, SCREEN );
    SDL_FreeSurface(MESSAGE);

    MESSAGE = TTF_RenderText_Solid( font,  "Ligne #5" , noir );
    apply_surface( 2, 531, MESSAGE, SCREEN );
    SDL_FreeSurface(MESSAGE);

    MESSAGE = TTF_RenderText_Solid( font,  "Ligne #6" , noir );
    apply_surface( 2, 538, MESSAGE, SCREEN );
    SDL_FreeSurface(MESSAGE);

    MESSAGE = TTF_RenderText_Solid( font,  "Ligne #7" , noir );
    apply_surface( 2, 545, MESSAGE, SCREEN );
    SDL_FreeSurface(MESSAGE);

    MESSAGE = TTF_RenderText_Solid( font,  "Ligne #8" , noir );
    apply_surface( 2, 552, MESSAGE, SCREEN );
    SDL_FreeSurface(MESSAGE);

    MESSAGE = TTF_RenderText_Solid( font,  "Ligne #9" , noir );
    apply_surface( 2, 559, MESSAGE, SCREEN );
    SDL_FreeSurface(MESSAGE);

    MESSAGE = TTF_RenderText_Solid( font,  "Ligne #10" , noir );
    apply_surface( 2, 566, MESSAGE, SCREEN );
    SDL_FreeSurface(MESSAGE);

    MESSAGE = TTF_RenderText_Solid( font,  "Ligne #11" , noir );
    apply_surface( 2, 574, MESSAGE, SCREEN );
    SDL_FreeSurface(MESSAGE);

    MESSAGE = TTF_RenderText_Solid( font,  "Ligne #12" , noir );
    apply_surface( 2, 581, MESSAGE, SCREEN );
    SDL_FreeSurface(MESSAGE);
}
0

There are 0 answers