1
class Renderer{
public:
    void text_to_sdl_surface(Text text, Colour colour);
    Font get_font(std::string font_name, int font_size);
private:
    SDL_Surface * text_surface;
};

void Renderer::text_to_sdl_surface(Text text, Colour colour) {
    glColor4f(1,1,1,1);
    SDL_Color text_colour;
    text_colour.r = Uint8(colour.get_colour_as_int()[0]);
    text_colour.g = Uint8(colour.get_colour_as_int()[1]);
    text_colour.b = Uint8(colour.get_colour_as_int()[2]);
    TTF_Font * temp_font = get_font(text.get_fontname(), text.get_fontsize()).get_font();
    text_surface = TTF_RenderText_Blended(temp_font, text.get_string().c_str(), text_colour);

}

SDL_TTF を使用してテキストを描画していますが、上記の関数、具体的には次の行に絞り込んだメモリ リークがあります。 text_surface = TTF_RenderText_Blended(temp_font, text.get_string().c_str(), text_colour);

opengl でサーフェスを使用した後、SDL_FreeSurface上記の関数が再度実行される前に呼び出していますが、まだリークしています。

4

0 に答える 0