]> git.imager.perl.org - imager.git/commitdiff
Removed a bunch of unused variables and fixed an attempt to print out a
authorArnar Mar Hrafnkelsson <addi@cpan.org>
Mon, 14 May 2001 05:52:53 +0000 (05:52 +0000)
committerArnar Mar Hrafnkelsson <addi@cpan.org>
Mon, 14 May 2001 05:52:53 +0000 (05:52 +0000)
structure pointer in error.c

Imager.xs
convert.c
error.c
filters.c
font.c
gif.c
image.c
image.h
io.c
quant.c
tiff.c

index d39a2a72f7cbab7178141b4fe54b6dcb31511004..e845d491ab3f0b113a870e6450250fbed904c46d 100644 (file)
--- a/Imager.xs
+++ b/Imager.xs
@@ -1163,10 +1163,6 @@ i_writegifmc(im,fd,colors)
               int     fd
               int     colors
 
-undef_int
-i_writegifex(im,fd)
-    Imager::ImgRaw     im
-              int     fd
 
 undef_int
 i_writegif_gen(fd, ...)
index 07a88fb2e7bf8a0a3ae62fd76bb44ac2e89fb43d..98c412418bf0b7ef65e8fa5694f1147d693dbdd9 100644 (file)
--- a/convert.c
+++ b/convert.c
@@ -44,7 +44,7 @@ i_convert(i_img *im, i_img *src, float *coeff, int outchan, int inchan)
   i_color *vals;
   int x, y;
   int i, j;
-  int ilimit, jlimit;
+  int ilimit;
   double work[MAXCHANNELS];
 
   mm_log((1,"i_convert(im* 0x%x, src, 0x%x, coeff 0x%x,outchan %d, inchan %d)\n",im,src, coeff,outchan, inchan));
diff --git a/error.c b/error.c
index 0edce898e62d8a8d5ea7c65a611e3ac133c00d9b..e350d3c5a1cdf5dbd0f95d303c370370d1e2fdb2 100644 (file)
--- a/error.c
+++ b/error.c
@@ -288,7 +288,7 @@ int i_failed(int code, char const *msg) {
     fputs("error:\n", stderr);
     sp = error_sp;
     while (error_stack[sp].msg) {
-      fprintf(stderr, " %s\n", error_stack[sp]);
+      fprintf(stderr, " %s\n", error_stack[sp].msg);
       ++sp;
     }
     /* we want to log the error too, build an error message to hand to
index 14ffb0b742bc8fc97cca8cfc8f9a30977828cdc1..3bcd6f747c80fee367c026337e92d8c81379a225 100644 (file)
--- a/filters.c
+++ b/filters.c
@@ -792,9 +792,7 @@ i_gradgen(i_img *im, int num, int *xo, int *yo, i_color *ival, int dmeasure) {
 void
 i_nearest_color_foo(i_img *im, int num, int *xo, int *yo, i_color *ival, int dmeasure) {
 
-  i_color val;
-  int p, x, y, ch;
-  int channels = im->channels;
+  int p, x, y;
   int xsize    = im->xsize;
   int ysize    = im->ysize;
 
@@ -869,7 +867,6 @@ i_nearest_color(i_img *im, int num, int *xo, int *yo, i_color *oval, int dmeasur
   float c1, c2;
   i_color val;
   int p, x, y, ch;
-  int channels = im->channels;
   int xsize    = im->xsize;
   int ysize    = im->ysize;
   int *cmatch;
diff --git a/font.c b/font.c
index 5f11121a473ee0ab2b319b771075f5a1b2fb4da5..2119aac0630f9e5406c2115fe0eb20e25eda72d8 100644 (file)
--- a/font.c
+++ b/font.c
@@ -1109,7 +1109,7 @@ i_tt_bbox_inst( TT_Fonthandle *handle, int inst ,const char *txt, int len, int c
   width   = 0;
   start   = 0;
   
-  mm_log((1, "i_tt_box_inst: glyph='%c' ascent=%d descent=%d\n", j, ascent, descent));
+  mm_log((1, "i_tt_box_inst: glyph='%c' gascent=%d gdescent=%d\n", j, gascent, gdescent));
 
   first=1;
   for ( i = 0; i < len; ++i ) {
diff --git a/gif.c b/gif.c
index 7dbfc42cee88dd416d96a91c1e7a0535bb002c02..236d9f4417a229d9f3084202993b456c0e4413ac 100644 (file)
--- a/gif.c
+++ b/gif.c
@@ -216,7 +216,7 @@ i_readgif_low(GifFileType *GifFile, int **colour_table, int *colours) {
       }
 
       if ( cmapcnt == 0) {
-       if (ColorMap = (GifFile->Image.ColorMap ? GifFile->Image.ColorMap : GifFile->SColorMap) ) {
+       if (( ColorMap = (GifFile->Image.ColorMap ? GifFile->Image.ColorMap : GifFile->SColorMap) )) {
          mm_log((1, "Adding local colormap\n"));
          ColorMapSize = ColorMap->ColorCount;
          i_colortable_copy(colour_table, colours, ColorMap);
@@ -439,104 +439,6 @@ i_writegifmc(i_img *im, int fd, int max_colors) {
   return i_writegif_gen(&quant, fd, &im, 1, &opts);
 }
 
-#if 1
-
-undef_int
-i_writegifex(i_img *im, int fd) {
-  return 0;
-}
-
-#else
-
-/* I don't think this works
-   note that RedBuffer is never allocated - TC
-*/
-
-undef_int
-i_writegifex(i_img *im,int fd) {
-  int colors, xsize, ysize, channels;
-  int x,y,ColorMapSize;
-  unsigned long Size;
-
-  struct octt *ct;
-
-  GifByteType *RedBuffer = NULL, *GreenBuffer = NULL, *BlueBuffer = NULL,*OutputBuffer = NULL;
-  ColorMapObject *OutputColorMap = NULL;
-  GifFileType *GifFile;
-  GifByteType *Ptr;
-  
-  i_color val;
-
-  mm_log((1,"i_writegif(0x%x,fd %d)\n",im,fd));
-  
-  if (!(im->channels==1 || im->channels==3)) { fprintf(stderr,"Unable to write gif, improper colorspace.\n"); exit(3); }
-
-  xsize=im->xsize;
-  ysize=im->ysize;
-  channels=im->channels;
-
-  colors=0;
-  ct=octt_new();
-
-  colors=0;
-  for(x=0;x<xsize;x++) for(y=0;y<ysize;y++) {
-    i_gpix(im,x,y,&val);
-    colors+=octt_add(ct,val.rgb.r,val.rgb.g,val.rgb.b);
-    /*  if (colors > maxc) { octt_delete(ct); } 
-       We'll just bite the bullet */
-  }
-
-  ColorMapSize = (colors > 256) ? 256 : colors;
-  
-  Size = ((long) im->xsize) * im->ysize * sizeof(GifByteType);
-  
-  if ((OutputColorMap = MakeMapObject(ColorMapSize, NULL)) == NULL)
-    m_fatal(0,"Failed to allocate memory for Output colormap.");
-  if ((OutputBuffer = (GifByteType *) mymalloc(im->xsize * im->ysize * sizeof(GifByteType))) == NULL)
-    m_fatal(0,"Failed to allocate memory for output buffer.");
-  
-  if (QuantizeBuffer(im->xsize, im->ysize, &ColorMapSize, RedBuffer, GreenBuffer, BlueBuffer,
-                    OutputBuffer, OutputColorMap->Colors) == GIF_ERROR) {
-    mm_log((1,"Error in QuantizeBuffer, unable to write image.\n"));
-    return(0);
-  }
-
-
-  myfree(RedBuffer);
-  if (im->channels == 3) { myfree(GreenBuffer); myfree(BlueBuffer); }
-  
-  if ((GifFile = EGifOpenFileHandle(fd)) == NULL) {
-    mm_log((1,"Error in EGifOpenFileHandle, unable to write image.\n"));
-    return(0);
-  }
-  
-  if (EGifPutScreenDesc(GifFile,im->xsize, im->ysize, colors, 0,OutputColorMap) == GIF_ERROR ||
-      EGifPutImageDesc(GifFile,0, 0, im->xsize, im->ysize, FALSE, NULL) == GIF_ERROR) {
-    mm_log((1,"Error in EGifOpenFileHandle, unable to write image.\n"));
-    if (GifFile != NULL) EGifCloseFile(GifFile);
-    return(0);
-  }
-
-  Ptr = OutputBuffer;
-
-  for (y = 0; y < im->ysize; y++) {
-    if (EGifPutLine(GifFile, Ptr, im->xsize) == GIF_ERROR) {
-      mm_log((1,"Error in EGifOpenFileHandle, unable to write image.\n"));
-      if (GifFile != NULL) EGifCloseFile(GifFile);
-      return(0);
-    }
-    
-    Ptr += im->xsize;
-  }
-  
-  if (EGifCloseFile(GifFile) == GIF_ERROR) {
-    mm_log((1,"Error in EGifCloseFile, unable to write image.\n"));
-    return(0);
-  }
-  return(1);
-}
-
-#endif
 
 /*
 =item i_readgif_scalar(char *data, int length, int **colour_table, int *colours)
@@ -802,7 +704,9 @@ static ColorMapObject *make_gif_map(i_quantize *quant, i_gif_opts *opts,
   /* giflib spews for 1 colour maps, reasonable, I suppose */
   if (map_size == 1)
     map_size = 2;
+  
   map = MakeMapObject(map_size, colors);
+  mm_log((1, "XXX map is at %p and colors at %p\n", map, map->Colors));
   if (!map) {
     gif_push_error();
     i_push_error(0, "Could not create color map object");
diff --git a/image.c b/image.c
index 767288f886cea060225883b4fd6fe43fbc5280f0..e8833ea4588c4f94979d1754a99ddedebd25ea06 100644 (file)
--- a/image.c
+++ b/image.c
@@ -491,9 +491,7 @@ Returns the number of pixels copied (eg. if r, l or y is out of range)
 =cut */
 int
 i_glin_d(i_img *im, int l, int r, int y, i_color *vals) {
-  int x, ch;
-  int count;
-  int i;
+  int ch, count, i;
   unsigned char *data;
   if (y >=0 && y < im->ysize && l < im->xsize && l >= 0) {
     if (r > im->xsize)
@@ -527,9 +525,7 @@ Returns the number of pixels copied (eg. if r, l or y is out of range)
 =cut */
 int
 i_plin_d(i_img *im, int l, int r, int y, i_color *vals) {
-  int x, ch;
-  int count;
-  int i;
+  int ch, count, i;
   unsigned char *data;
   if (y >=0 && y < im->ysize && l < im->xsize && l >= 0) {
     if (r > im->xsize)
@@ -655,7 +651,7 @@ Copies the contents of the image I<src> over the image I<im>.
 void
 i_copy(i_img *im, i_img *src) {
   i_color *pv;
-  int x,y,y1,x1;
+  int y, y1, x1;
 
   mm_log((1,"i_copy(im* %p,src %p)\n", im, src));
 
diff --git a/image.h b/image.h
index ac76ecd6722c0dffab9cea7c08dd2472e2de6bb9..1a1d5522cb3a7a669cdae961908ba11477f42639 100644 (file)
--- a/image.h
+++ b/image.h
@@ -461,6 +461,7 @@ typedef struct {
   char *msg;
   int code;
 } i_errmsg;
+
 typedef void (*i_error_cb)(int code, char const *msg);
 typedef void (*i_failed_cb)(i_errmsg *msgs);
 extern i_error_cb i_set_error_cb(i_error_cb);
diff --git a/io.c b/io.c
index ca38fa9b2d8376275ea0fff660e7739260d0098d..6bc0bbf16c5f317f7c2b737c315af01245f657f1 100644 (file)
--- a/io.c
+++ b/io.c
@@ -13,8 +13,8 @@
 #define MAXMAL 102400
 #define MAXDESC 65
 
-#define UNDRRNVAL 100
-#define OVERRNVAL 100
+#define UNDRRNVAL 10
+#define OVERRNVAL 10
 
 #define PADBYTE 0xaa
 
@@ -55,7 +55,7 @@ mymalloc_file_line(int size, char* file, int line) {
   int i;
   if (malloc_need_init) {
     for(i=0; i<MAXMAL; i++) malloc_pointers[i].point = NULL;
-    malloc_need_init=0;
+    malloc_need_init = 0;
     atexit(malloc_state);
   }
 
@@ -157,7 +157,7 @@ myfree_file_line(void *p, char *file, int line) {
   }
   
   if (match != 1) {
-    mm_log((1, "myfree_file_line: inconsistent refcount %d\n", match));
+    mm_log((1, "myfree_file_line: INCONSISTENT REFCOUNT %d\n", match));
   }
   
   mm_log((1, "myfree_file_line: freeing address %p\n", pp-UNDRRNVAL));
@@ -179,7 +179,7 @@ mymalloc(int size) {
   void *buf;
 
   mm_log((1, "mymalloc(size %d)\n", size));
-  if ( (buf=malloc(size)) == NULL ) {
+  if ( (buf = malloc(size)) == NULL ) {
     mm_log((1, "mymalloc: unable to malloc\n", size));
     fprintf(stderr,"Unable to malloc.\n"); exit(3);
   }
diff --git a/quant.c b/quant.c
index e257b8f53d75c1d7a7e1b0a92760e97e7709d2ea..a149cd1606bcb088a36a3e8f802d0b2df8d67362 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) 
diff --git a/tiff.c b/tiff.c
index 2587c13aa68e278b1af04d8f8fa0276664268e86..05a44edf18abe6207c012d60e0a41ef49f85e0e5 100644 (file)
--- a/tiff.c
+++ b/tiff.c
@@ -362,11 +362,9 @@ point.
 undef_int
 i_writetiff_wiol_faxable(i_img *im, io_glue *ig) {
   uint32 width, height;
-  i_color val;
   unsigned char *linebuf = NULL;
   uint32 y;
-  int linebufpos;
-  int ch, ci, rc;
+  int rc;
   uint32 x;
   TIFF* tif;
   int luma_channel;