]> git.imager.perl.org - imager.git/blobdiff - quant.c
both done
[imager.git] / quant.c
diff --git a/quant.c b/quant.c
index 3787008d34642b665037999a1d9aa0607d17d1a2..f745f6fba0e951e53b66d5db5649e921b1f3f1fe 100644 (file)
--- a/quant.c
+++ b/quant.c
@@ -27,7 +27,6 @@ setcol(i_color *cl,unsigned char r,unsigned char g,unsigned char b,unsigned char
 
 void
 quant_makemap(i_quantize *quant, i_img **imgs, int count) {
-       i_color temp;
 #ifdef HAVE_LIBGIF
   /* giflib does it's own color table generation */
   if (quant->translate == pt_giflib) 
@@ -68,7 +67,11 @@ static void translate_addi(i_quantize *, i_img *, i_palidx *);
    The giflib quantizer ignores the palette.
 */
 i_palidx *quant_translate(i_quantize *quant, i_img *img) {
-  i_palidx *result = mymalloc(img->xsize * img->ysize);
+  i_palidx *result;
+       mm_log((1, "quant_translate(quant %p, img %p)\n", quant, img));
+
+       result = mymalloc(img->xsize * img->ysize);
+
   switch (quant->translate) {
 #ifdef HAVE_LIBGIF
   case pt_giflib:
@@ -115,7 +118,7 @@ static void translate_giflib(i_quantize *quant, i_img *img, i_palidx *out) {
   
   i_color col;
 
-  /*mm_log((1,"i_writegif(0x%x, fd %d, colors %dbpp)\n",im,fd,colors));*/
+       mm_log((1,"i_writegif(quant %p, img %p, out %p)\n", quant, img, out));
   
   /*if (!(im->channels==1 || im->channels==3)) { fprintf(stderr,"Unable to write gif, improper colorspace.\n"); exit(3); }*/
   
@@ -151,14 +154,14 @@ static void translate_giflib(i_quantize *quant, i_img *img, i_palidx *out) {
       }
       if ((GreenBuffer = (GifByteType *) mymalloc((unsigned int) Size)) == NULL) {
         m_fatal(0,"Failed to allocate memory required, aborted.");
-        free(RedBuffer);
+        myfree(RedBuffer);
         return;
       }
     
       if ((BlueBuffer  = (GifByteType *) mymalloc((unsigned int) Size)) == NULL) {
         m_fatal(0,"Failed to allocate memory required, aborted.");
-        free(RedBuffer);
-        free(GreenBuffer);
+        myfree(RedBuffer);
+        myfree(GreenBuffer);
         return;
       }
     
@@ -194,8 +197,8 @@ static void translate_giflib(i_quantize *quant, i_img *img, i_palidx *out) {
     }
   }
 
-  free(RedBuffer);
-  if (img->channels == 3) { free(GreenBuffer); free(BlueBuffer); }
+  myfree(RedBuffer);
+  if (img->channels == 3) { myfree(GreenBuffer); myfree(BlueBuffer); }
 
   /* copy over the color map */
   for (i = 0; i < ColorMapSize; ++i) {
@@ -623,7 +626,7 @@ static void hbsetup(i_quantize *quant, hashbox *hb) {
 #endif
       } 
     } 
-  } 
+  }
 #ifdef HB_SORT
   myfree(indices); 
 #endif