Commit d7cd7612a2e578a810e31761db522a2d28b678ae

henry 2003-04-02T23:47:27

Fixed memory leaks

diff --git a/include/FTList.h b/include/FTList.h
index 23c3105..f942d57 100644
--- a/include/FTList.h
+++ b/include/FTList.h
@@ -31,12 +31,12 @@ class FTGL_EXPORT FTList
          */
         ~FTList()
         {
-            Node* temp = head;
+            Node* next;
             
-            while( temp->next)
+            for (Node *walk = head;walk;walk = next)
             {
-                temp = head->next;
-                delete head;
+                next = walk->next;
+                delete walk;
             }
         }
 
@@ -59,11 +59,12 @@ class FTGL_EXPORT FTList
             {
                 head->next = node;
             }
-            
+
+            if (tail) tail->next = node;
             tail = node;
             ++listSize;
         }
-
+        
         /**
          * Get the item at the front of the list
          */
diff --git a/src/FTOutlineGlyph.cpp b/src/FTOutlineGlyph.cpp
index d2d290f..c1fe64c 100644
--- a/src/FTOutlineGlyph.cpp
+++ b/src/FTOutlineGlyph.cpp
@@ -11,12 +11,11 @@ FTOutlineGlyph::FTOutlineGlyph( FT_Glyph glyph)
         return;
     }
 
-    FTVectoriser* vectoriser = new FTVectoriser( glyph);
+    FTVectoriser vectoriser( glyph);
 
-    size_t numContours = vectoriser->ContourCount();
-    if ( ( numContours < 1) || ( vectoriser->PointCount() < 3))
+    size_t numContours = vectoriser.ContourCount();
+    if ( ( numContours < 1) || ( vectoriser.PointCount() < 3))
     {
-        delete vectoriser;
         return;
     }
 
@@ -24,7 +23,7 @@ FTOutlineGlyph::FTOutlineGlyph( FT_Glyph glyph)
     glNewList( glList, GL_COMPILE);
         for( unsigned int c = 0; c < numContours; ++c)
         {
-            const FTContour* contour = vectoriser->Contour(c);
+            const FTContour* contour = vectoriser.Contour(c);
             
             glBegin( GL_LINE_LOOP);
                 for( unsigned int p = 0; p < contour->PointCount(); ++p)
@@ -35,7 +34,6 @@ FTOutlineGlyph::FTOutlineGlyph( FT_Glyph glyph)
         }
     glEndList();
 
-    delete vectoriser;
 
     // discard glyph image (bitmap or not)
     FT_Done_Glyph( glyph); // Why does this have to be HERE
diff --git a/src/FTPolyGlyph.cpp b/src/FTPolyGlyph.cpp
index dded757..fbd7cb2 100644
--- a/src/FTPolyGlyph.cpp
+++ b/src/FTPolyGlyph.cpp
@@ -11,20 +11,19 @@ FTPolyGlyph::FTPolyGlyph( FT_Glyph glyph)
         return;
     }
 
-    FTVectoriser* vectoriser = new FTVectoriser( glyph);
+    FTVectoriser vectoriser( glyph);
 
-    if(( vectoriser->ContourCount() < 1) || ( vectoriser->PointCount() < 3))
+    if(( vectoriser.ContourCount() < 1) || ( vectoriser.PointCount() < 3))
     {
-        delete vectoriser;
         return;
     }
 
-    vectoriser->MakeMesh( 1.0);
+    vectoriser.MakeMesh( 1.0);
     
     glList = glGenLists( 1);
     glNewList( glList, GL_COMPILE);
 
-        const FTMesh* mesh = vectoriser->GetMesh();
+        const FTMesh* mesh = vectoriser.GetMesh();
         for( unsigned int index = 0; index < mesh->TesselationCount(); ++index)
         {
             const FTTesselation* subMesh = mesh->Tesselation( index);
diff --git a/src/FTVectoriser.cpp b/src/FTVectoriser.cpp
index cca5c36..4829594 100644
--- a/src/FTVectoriser.cpp
+++ b/src/FTVectoriser.cpp
@@ -1,7 +1,6 @@
 #include    "FTVectoriser.h"
 #include    "FTGL.h"
 
-
 #ifndef CALLBACK
 #define CALLBACK
 #endif