Added Destroy method for Imager::Font::TT and moved to that package name
authorArnar Mar Hrafnkelsson <addi@cpan.org>
Thu, 1 Nov 2001 11:35:04 +0000 (11:35 +0000)
committerArnar Mar Hrafnkelsson <addi@cpan.org>
Thu, 1 Nov 2001 11:35:04 +0000 (11:35 +0000)
the tt handles.  Other miscelleanious memory leaks sealed.

Changes
Imager.xs
draw.c
font.c
t/t35ttfont.t
typemap

diff --git a/Changes b/Changes
index 5fd50fc..3e5606c 100644 (file)
--- a/Changes
+++ b/Changes
@@ -541,7 +541,7 @@ Revision history for Perl extension Imager.
         - io_buffer implemented as a source for io layer and
           XS and perl OO code added.
         - Test for iolayer t/t07iolayer.t implemented.
-
+       - Fixed most known memory leaks.
 
 =================================================================
 
index 0a90145..290497d 100644 (file)
--- a/Imager.xs
+++ b/Imager.xs
@@ -21,7 +21,7 @@ typedef i_img*   Imager__ImgRaw;
 
 
 #ifdef HAVE_LIBTT
-typedef TT_Fonthandle* Imager__TTHandle;
+typedef TT_Fonthandle* Imager__Font__TT;
 #endif
 
 #ifdef HAVE_FT2
@@ -1258,19 +1258,26 @@ i_t1_text(im,xb,yb,cl,fontnum,points,str,len,align)
 #ifdef HAVE_LIBTT
 
 
-Imager::TTHandle
+Imager::Font::TT
 i_tt_new(fontname)
              char*     fontname
 
+
+MODULE = Imager         PACKAGE = Imager::Font::TT      PREFIX=TT_
+
+#define TT_DESTROY(handle) i_tt_destroy(handle)
+
 void
-i_tt_destroy(handle)
-     Imager::TTHandle    handle
+TT_DESTROY(handle)
+     Imager::Font::TT   handle
 
 
+MODULE = Imager         PACKAGE = Imager
+
 
 undef_int
 i_tt_text(handle,im,xb,yb,cl,points,str,len,smooth)
-  Imager::TTHandle     handle
+  Imager::Font::TT     handle
     Imager::ImgRaw     im
               int     xb
               int     yb
@@ -1283,7 +1290,7 @@ i_tt_text(handle,im,xb,yb,cl,points,str,len,smooth)
 
 undef_int
 i_tt_cp(handle,im,xb,yb,channel,points,str,len,smooth)
-  Imager::TTHandle     handle
+  Imager::Font::TT     handle
     Imager::ImgRaw     im
               int     xb
               int     yb
@@ -1297,7 +1304,7 @@ i_tt_cp(handle,im,xb,yb,channel,points,str,len,smooth)
 
 undef_int
 i_tt_bbox(handle,point,str,len)
-  Imager::TTHandle     handle
+  Imager::Font::TT     handle
             float     point
              char*    str
               int     len
diff --git a/draw.c b/draw.c
index 1656105..5ad73f1 100644 (file)
--- a/draw.c
+++ b/draw.c
@@ -335,6 +335,7 @@ i_circle_aa(i_img *im, float x, float y, float rad, i_color *val) {
       }
     }
   }
+  i_mmarray_dst(&dot);
 }
 
 
diff --git a/font.c b/font.c
index 1b76467..c778424 100644 (file)
--- a/font.c
+++ b/font.c
@@ -538,7 +538,7 @@ i_tt_new(char *fontname) {
   
   /* allocate memory for the structure */
   
-  handle=mymalloc( sizeof(TT_Fonthandle) );
+  handle = mymalloc( sizeof(TT_Fonthandle) );
 
   /* load the typeface */
   error = TT_Open_Face( engine, fontname, &handle->face );
@@ -782,6 +782,7 @@ pixmaps and glyphs
 void
 i_tt_destroy( TT_Fonthandle *handle) {
   TT_Close_Face( handle->face );
+  myfree( handle );
   
   /* FIXME: Should these be freed automatically by the library? 
 
index 7825f85..d4fb51f 100644 (file)
@@ -34,15 +34,15 @@ if (! -f $fontname) {
 i_init_fonts();
 #     i_tt_set_aa(1);
 
-$bgcolor=i_color_new(255,0,0,0);
-$overlay=Imager::ImgRaw::new(200,70,3);
+$bgcolor = i_color_new(255,0,0,0);
+$overlay = Imager::ImgRaw::new(200,70,3);
 
-$ttraw=Imager::i_tt_new($fontname);
+$ttraw = Imager::i_tt_new($fontname);
 
 #use Data::Dumper;
 #warn Dumper($ttraw);
 
-@bbox=i_tt_bbox($ttraw,50.0,'XMCLH',5);
+@bbox = i_tt_bbox($ttraw,50.0,'XMCLH',5);
 print "#bbox: ($bbox[0], $bbox[1]) - ($bbox[2], $bbox[3])\n";
 
 i_tt_cp($ttraw,$overlay,5,50,1,50.0,'XMCLH',5,1);
diff --git a/typemap b/typemap
index f39ed30..f6b5688 100644 (file)
--- a/typemap
+++ b/typemap
@@ -2,7 +2,7 @@
 Imager::Color           T_PTROBJ
 Imager::Color::Float    T_PTROBJ
 Imager::ImgRaw          T_PTROBJ
-Imager::TTHandle       T_PTROBJ
+Imager::Font::TT       T_PTROBJ
 Imager::IO              T_PTROBJ
 Imager::Font::FT2       T_PTROBJ
 Imager::FillHandle      T_PTROBJ