freetype-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AW: [Devel] Leaking FT_Glyph_To_Bitmap


From: David Turner
Subject: Re: AW: [Devel] Leaking FT_Glyph_To_Bitmap
Date: Thu, 23 Jan 2003 00:03:32 +0100
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.2.1) Gecko/20021130

Hello Patrick,

  I believe that what is really confusing is that the function
  FT_Glyph_To_Bitmap creates a new FT_Glyph and overwrites the
  source's handle to point to it in case of success (in case of
  failure, the original pointer is left untouched)

  we'd probably provide a better way to perform the same thing,
  what about:

  FT_EXPORT( FT_Error )
  FT_Get_Glyph_Bitmap( FT_Glyph         source,
                       FT_Render_Mode   render_mode,
                       FT_Vector*       origin,
                       FT_BitmapGlyph  *aglyph );

  with this function, the code for FT_Get_Glyph_Bitmap really
  becomes:

  FT_Error
  FT_Glyph_To_Bitmap( FT_Glyph       *the_glyph,
                      FT_Render_Mode  render_mode,
                      FT_Vector*      origin,
                      FT_Bool         destroy )
  {
    FT_Error         error;
    FT_BitmapGlyph   result;

    error = FT_Get_Glyph_Bitmap( *the_glyph, render_mode,
                                 origin, &result );
    if ( !error )
    {
      if ( destroy )
        FT_Done_Glyph( *the_glyph );

      *the_glyph = (FT_Glyph) result;
    }
    return  error;
  }

  Hope this helps,

- David Turner
- The FreeType Project  (www.freetype.org)



Patrick Hoffmann wrote:
I do call FT_Done_Glyph() (later in my code) and it works mostly fine.
Except the struct created by FT_Glyph_To_Bitmap! I have to delete it
manually before calling FT_Done_Glyph().

-----Ursprüngliche Nachricht-----
Von: address@hidden [mailto:address@hidden Im
Auftrag von David Turner
Gesendet: Freitag, 17. Januar 2003 16:32
An: address@hidden
Betreff: Re: [Devel] Leaking FT_Glyph_To_Bitmap


Hello Patrick,

Patrick Hoffmann wrote:

Hi freetype folx...

I found a leak (or a misktake of myself ;) in FreeType 2.

When I user FT_Glyph_To_Bitmap() I need to delete the bitmap buffer and the bitmap it self by my own. I didn't found any hint about that in the documentation, so I think this might be a memory leak bug.

Any ideas?


FT_Glyph objects are not monitored by the library, you need to destroy
them yourself (unlike FT_Size/FT_GlyphSlot/FT_CharMap objects which are
automatically destroyed when FT_Done_Face or FT_Done_FreeType are
called)

When FT_Glyph_To_Bitmap is called, it really creates a new FT_Glyph
object and changes your "image" handle to point to it. you should call
FT_Done_Glyph to destroy it when you don't need it anymore..

I don't think this is a memory leak, just normal behaviour for the
library...

Hope this helps,

- David Turner
- The FreeType Project  (www.freetype.org)



Here is the code...

        FT_Glyph        image = it->m_ftglyph;

        e = FT_Glyph_To_Bitmap( &image, ft_render_mode_normal, &pen, 0
);
        if( !e )
        {
                FT_BitmapGlyph  bit = (FT_BitmapGlyph)image;

                Driver_Display_Bitmap( ... );

                // Undocumented: must delete these both...
                delete [] bit->bitmap.buffer;
                delete bit;
        }


_______________________________________________
Devel mailing list
address@hidden http://www.freetype.org/mailman/listinfo/devel





_______________________________________________
Devel mailing list
address@hidden http://www.freetype.org/mailman/listinfo/devel


_______________________________________________
Devel mailing list
address@hidden
http://www.freetype.org/mailman/listinfo/devel






reply via email to

[Prev in Thread] Current Thread [Next in Thread]