]> git.imager.perl.org - imager.git/commitdiff
Code to free up resources for Imager::IO objects.
authorArnar Mar Hrafnkelsson <addi@cpan.org>
Mon, 22 Oct 2001 11:35:57 +0000 (11:35 +0000)
committerArnar Mar Hrafnkelsson <addi@cpan.org>
Mon, 22 Oct 2001 11:35:57 +0000 (11:35 +0000)
Changes
Imager.xs
iolayer.c

diff --git a/Changes b/Changes
index c5af246ad9099ba23fec3c26f2bb1a3558c06505..fdedc24c6dbaf7cc9b52604cadad4ffe11ab9044 100644 (file)
--- a/Changes
+++ b/Changes
@@ -470,16 +470,16 @@ Revision history for Perl extension Imager.
         - some utf8 support for freetype2
         - some vertical layout support for freetype2
         - named parameters for specifying colors, with quite a few options.
         - some utf8 support for freetype2
         - some vertical layout support for freetype2
         - named parameters for specifying colors, with quite a few options.
-       - glyph size issues for freetyp2
+        - glyph size issues for freetyp2
         - minor problem in handling of canon option
         - low-level bmp writing (moving it to laptop)
         - Windows BMP reading and writing
         - added OO interfaces for the mosaic, bumpmap, postlevels and
           watermark filters
         - added t/t61filters.t to test the filters
         - minor problem in handling of canon option
         - low-level bmp writing (moving it to laptop)
         - Windows BMP reading and writing
         - added OO interfaces for the mosaic, bumpmap, postlevels and
           watermark filters
         - added t/t61filters.t to test the filters
-       - fixed some problems in jpeg handling from the exp_represent merge
+        - fixed some problems in jpeg handling from the exp_represent merge
         - fixed buffer flushing for wiol jpeg code
         - fixed buffer flushing for wiol jpeg code
-       - added some tests that will hopefully catch it in the future
+        - added some tests that will hopefully catch it in the future
         - added the OO interfaces to the mosaic, bumpmap, postlevels and
           watermark filters, and documented them
         - fixed a sample size conversion problem in i_gpixf_d() etc.
         - added the OO interfaces to the mosaic, bumpmap, postlevels and
           watermark filters, and documented them
         - fixed a sample size conversion problem in i_gpixf_d() etc.
@@ -520,12 +520,15 @@ Revision history for Perl extension Imager.
         - adjust ascender/descender values for FT1.x to avoid losing
           descenders (specifically the bottom of "g" in ImUgly.ttf or
           arial.ttf at 14pixels)
         - adjust ascender/descender values for FT1.x to avoid losing
           descenders (specifically the bottom of "g" in ImUgly.ttf or
           arial.ttf at 14pixels)
-        - Added tga.c to read targa images
-        - Added i_bumpmap_complex to do more accurate bumpmapping
+        - added tga.c to read targa images
+        - added i_bumpmap_complex to do more accurate bumpmapping
         - added an image type with doubles as samples
         - change i_copy() and i_sametype() to handle double/sample images
         - added basic POD to trans2.c
         - transform2 now uses the error interface
         - added an image type with doubles as samples
         - change i_copy() and i_sametype() to handle double/sample images
         - added basic POD to trans2.c
         - transform2 now uses the error interface
+        - myrealloc() is implemented for malloc debug mode
+        - now buffer chains are freed when destructor for Imager::IOi
+          is called
 
 =================================================================
 
 
 =================================================================
 
index b8fe938402ebcd86b732b07402eb73e496b15a13..b8bf826686b3b303138416086bbfd212d7152815 100644 (file)
--- a/Imager.xs
+++ b/Imager.xs
@@ -690,6 +690,18 @@ io_slurp(ig)
               myfree(data);
 
 
               myfree(data);
 
 
+MODULE = Imager                PACKAGE = Imager::IO    PREFIX = io_glue_
+
+void
+io_glue_DESTROY(ig)
+        Imager::IO     ig
+
+
+MODULE = Imager                PACKAGE = Imager
+
+PROTOTYPES: ENABLE
+
+
 
 void
 i_list_formats()
 
 void
 i_list_formats()
index 45ee234a64bf7505bf0a6a81ebc37b109602ed66..ef48c6947ccc3b2636f75683dbf8ddecfcd83b7e 100644 (file)
--- a/iolayer.c
+++ b/iolayer.c
@@ -246,6 +246,28 @@ io_bchain_advance(io_ex_bchain *ieb) {
 }
 
 
 }
 
 
+
+/*
+=item io_bchain_destroy()
+
+frees all resources used by a buffer chain.
+
+=cut
+*/
+
+void
+io_destroy_bufchain(io_ex_bchain *ieb) {
+  io_blink *cp = ieb->head;
+  while(cp) {
+    io_blink *t = cp->next;
+    free(cp);
+    cp = t;
+  }
+}
+
+
+
+
 /*
 
 static
 /*
 
 static
@@ -686,7 +708,7 @@ io_glue_commit_types(io_glue *ig) {
       ieb->cpos   = 0;
       ieb->gpos   = 0;
       ieb->tfill  = 0;
       ieb->cpos   = 0;
       ieb->gpos   = 0;
       ieb->tfill  = 0;
-      
+
       ieb->head   = io_blink_new();
       ieb->cp     = ieb->head;
       ieb->tail   = ieb->head;
       ieb->head   = io_blink_new();
       ieb->cp     = ieb->head;
       ieb->tail   = ieb->head;
@@ -760,6 +782,12 @@ io_new_bufchain() {
 }
 
 
 }
 
 
+
+
+
+
+
+
 /*
 =item io_new_fd(fd)
 
 /*
 =item io_new_fd(fd)
 
@@ -841,6 +869,23 @@ Might leave us with a dangling pointer issue on some buffers.
 
 void
 io_glue_DESTROY(io_glue *ig) {
 
 void
 io_glue_DESTROY(io_glue *ig) {
-  free(ig);
-  /* FIXME: Handle extradata and such */
+  io_type      inn = ig->source.type;
+  mm_log((1, "io_glue_DESTROY(ig %p)\n", ig));
+  
+  switch (inn) {
+  case BUFCHAIN:
+    {
+      io_ex_bchain *ieb = ig->exdata;
+      io_destroy_bufchain(ieb);
+    }
+    break;
+  case CBSEEK:
+  default:
+    {
+      io_ex_rseek *ier = ig->exdata;
+      myfree(ier);
+    }
+
+  }
+  myfree(ig);
 }
 }