Commit d30f9095284376628dfa926588ffaa6a56e3cdba

sammy 2008-05-02T12:43:22

* Fix a potential memory leak in the FTGlyph C bindings error handler.

diff --git a/src/FTGlyph/FTGlyphGlue.cpp b/src/FTGlyph/FTGlyphGlue.cpp
index f894e25..71e394f 100644
--- a/src/FTGlyph/FTGlyphGlue.cpp
+++ b/src/FTGlyph/FTGlyphGlue.cpp
@@ -30,6 +30,9 @@
 
 #include "FTInternals.h"
 
+static FTPoint static_ftpoint;
+static FTBBox static_ftbbox;
+
 FTGL_BEGIN_C_DECLS
 
 #define C_TOR(cname, cargs, cxxname, cxxarg, cxxtype) \
@@ -139,7 +142,7 @@ void ftglDestroyGlyph(FTGLglyph *g)
 // const FTPoint& FTGlyph::Render(const FTPoint& pen, int renderMode);
 C_FUN(static const FTPoint&, _ftglGlyphRender, (FTGLglyph *g,
                                    const FTPoint& pen, int renderMode),
-      return *(new FTPoint()), Render, (pen, renderMode));
+      return static_ftpoint, Render, (pen, renderMode));
 
 void ftglGlyphRender(FTGLglyph *g, FTGL_DOUBLE penx, FTGL_DOUBLE peny,
                      int renderMode, FTGL_DOUBLE *advancex,
@@ -153,7 +156,7 @@ void ftglGlyphRender(FTGLglyph *g, FTGL_DOUBLE penx, FTGL_DOUBLE peny,
 
 // const FTPoint& FTGlyph::Advance() const;
 C_FUN(static const FTPoint&, _ftglGlyphAdvance, (FTGLglyph *g),
-      return *(new FTPoint()), Advance, ());
+      return static_ftpoint, Advance, ());
 
 void ftglGlyphAdvance(FTGLglyph *g, FTGL_DOUBLE *advancex,
                       FTGL_DOUBLE *advancey)
@@ -165,7 +168,7 @@ void ftglGlyphAdvance(FTGLglyph *g, FTGL_DOUBLE *advancex,
 
 // const FTBBox& FTGlyph::BBox() const;
 C_FUN(static const FTBBox&, _ftglGlyphBBox, (FTGLglyph *g),
-      return *(new FTBBox()), BBox, ());
+      return static_ftbbox, BBox, ());
 
 void ftglGlyphBBox(FTGLglyph *g, float *lx, float *ly, float *lz,
                    float *ux, float *uy, float *uz)