Commit dfa07fc3085fe9de59d824b8ff47c4823ee5e175

sammy 2008-05-02T07:20:51

* Fix a small memory leak in the C bindings destructors.

diff --git a/src/FTFont/FTFontGlue.cpp b/src/FTFont/FTFontGlue.cpp
index 1a0f631..ace0bdb 100644
--- a/src/FTFont/FTFontGlue.cpp
+++ b/src/FTFont/FTFontGlue.cpp
@@ -125,6 +125,7 @@ void ftglDestroyFont(FTGLfont *f)
     }
 
     f->ptr = NULL;
+    free(f);
 }
 
 // bool FTFont::Attach(const char* fontFilePath);
diff --git a/src/FTGlyph/FTGlyphGlue.cpp b/src/FTGlyph/FTGlyphGlue.cpp
index 6957d05..f894e25 100644
--- a/src/FTGlyph/FTGlyphGlue.cpp
+++ b/src/FTGlyph/FTGlyphGlue.cpp
@@ -133,6 +133,7 @@ void ftglDestroyGlyph(FTGLglyph *g)
     }
 
     g->ptr = NULL;
+    free(g);
 }
 
 // const FTPoint& FTGlyph::Render(const FTPoint& pen, int renderMode);
diff --git a/src/FTLayout/FTLayoutGlue.cpp b/src/FTLayout/FTLayoutGlue.cpp
index b4b877e..3772f36 100644
--- a/src/FTLayout/FTLayoutGlue.cpp
+++ b/src/FTLayout/FTLayoutGlue.cpp
@@ -66,23 +66,24 @@ C_TOR(ftglCreateSimpleLayout, (), FTSimpleLayout, (), LAYOUT_SIMPLE);
     }
 
 // FTLayout::~FTLayout();
-void ftglDestroyLayout(FTGLlayout *f)
+void ftglDestroyLayout(FTGLlayout *l)
 {
-    if(!f || !f->ptr)
+    if(!l || !l->ptr)
     {
         fprintf(stderr, "FTGL warning: NULL pointer in %s\n", __FUNCTION__);
         return;
     }
-    switch(f->type)
+    switch(l->type)
     {
         case FTGL::LAYOUT_SIMPLE:
-            delete dynamic_cast<FTSimpleLayout*>(f->ptr); break;
+            delete dynamic_cast<FTSimpleLayout*>(l->ptr); break;
         default:
             fprintf(stderr, "FTGL warning: %s not implemented for %d\n",
-                            __FUNCTION__, f->type);
+                            __FUNCTION__, l->type);
     }
 
-    f->ptr = NULL;
+    l->ptr = NULL;
+    free(l);
 }
 
 // virtual void BBox(const char* string, float& llx, float& lly, float& llz, float& urx, float& ury, float& urz)