]> git.imager.perl.org - imager.git/commitdiff
avoid i_push_errorf() and i_fatal() in a few more places
authorTony Cook <tony@develop-help.com>
Mon, 13 Aug 2012 08:12:07 +0000 (18:12 +1000)
committerTony Cook <tony@develop-help.com>
Tue, 14 Aug 2012 09:58:20 +0000 (19:58 +1000)
bmp.c
datatypes.c
filters.im
hlines.c
image.c
img8.c

diff --git a/bmp.c b/bmp.c
index 10e463cf39f8458d1e716618c911b7d16faf48e6..0e8fe8e75c2ee9674106979f611612fcb5a3ca59 100644 (file)
--- a/bmp.c
+++ b/bmp.c
@@ -768,13 +768,13 @@ read_1bit_bmp(io_glue *ig, int xsize, int ysize, int clr_used,
   if (!clr_used)
     clr_used = 2;
   if (clr_used < 0 || clr_used > 2) {
-    i_push_errorf(0, "out of range colors used (%d)", clr_used);
+    im_push_errorf(aIMCTX, 0, "out of range colors used (%d)", clr_used);
     return NULL;
   }
 
   base_offset = FILEHEAD_SIZE + INFOHEAD_SIZE + clr_used * 4;
   if (offbits < base_offset) {
-    i_push_errorf(0, "image data offset too small (%ld)", offbits);
+    im_push_errorf(aIMCTX, 0, "image data offset too small (%ld)", offbits);
     return NULL;
   }
 
@@ -886,13 +886,13 @@ read_4bit_bmp(io_glue *ig, int xsize, int ysize, int clr_used,
     clr_used = 16;
 
   if (clr_used > 16 || clr_used < 0) {
-    i_push_errorf(0, "out of range colors used (%d)", clr_used);
+    im_push_errorf(aIMCTX, 0, "out of range colors used (%d)", clr_used);
     return NULL;
   }
 
   base_offset = FILEHEAD_SIZE + INFOHEAD_SIZE + clr_used * 4;
   if (offbits < base_offset) {
-    i_push_errorf(0, "image data offset too small (%ld)", offbits);
+    im_push_errorf(aIMCTX, 0, "image data offset too small (%ld)", offbits);
     return NULL;
   }
 
@@ -1069,7 +1069,7 @@ read_4bit_bmp(io_glue *ig, int xsize, int ysize, int clr_used,
   else { /*if (compression == BI_RLE4) {*/
     myfree(packed);
     myfree(line);
-    i_push_errorf(0, "unknown 4-bit BMP compression (%d)", compression);
+    im_push_errorf(aIMCTX, 0, "unknown 4-bit BMP compression (%d)", compression);
     i_img_destroy(im);
     return NULL;
   }
@@ -1118,13 +1118,13 @@ read_8bit_bmp(io_glue *ig, int xsize, int ysize, int clr_used,
   if (!clr_used)
     clr_used = 256;
   if (clr_used > 256 || clr_used < 0) {
-    i_push_errorf(0, "out of range colors used (%d)", clr_used);
+    im_push_errorf(aIMCTX, 0, "out of range colors used (%d)", clr_used);
     return NULL;
   }
 
   base_offset = FILEHEAD_SIZE + INFOHEAD_SIZE + clr_used * 4;
   if (offbits < base_offset) {
-    i_push_errorf(0, "image data offset too small (%ld)", offbits);
+    im_push_errorf(aIMCTX, 0, "image data offset too small (%ld)", offbits);
     return NULL;
   }
 
@@ -1267,7 +1267,7 @@ read_8bit_bmp(io_glue *ig, int xsize, int ysize, int clr_used,
   }
   else { 
     myfree(line);
-    i_push_errorf(0, "unknown 8-bit BMP compression (%d)", compression);
+    im_push_errorf(aIMCTX, 0, "unknown 8-bit BMP compression (%d)", compression);
     i_img_destroy(im);
     return NULL;
   }
@@ -1387,7 +1387,7 @@ read_direct_bmp(io_glue *ig, int xsize, int ysize, int bit_count,
         return 0;
       }
       if (rmask == 0) {
-       i_push_errorf(0, "Zero mask for channel %d", i);
+       im_push_errorf(aIMCTX, 0, "Zero mask for channel %d", i);
        return NULL;
       }
       masks.masks[i] = rmask;
@@ -1411,12 +1411,12 @@ read_direct_bmp(io_glue *ig, int xsize, int ysize, int bit_count,
     base_offset += 3 * 4;
   }
   else {
-    i_push_errorf(0, "unknown 24-bit BMP compression (%d)", compression);
+    im_push_errorf(aIMCTX, 0, "unknown 24-bit BMP compression (%d)", compression);
     return NULL;
   }
 
   if (offbits < base_offset) {
-    i_push_errorf(0, "image data offset too small (%ld)", offbits);
+    im_push_errorf(aIMCTX, 0, "image data offset too small (%ld)", offbits);
     return NULL;
   }
 
index 3da4c5b0d7dba2cf3fdb59e384e33b98f1dfe87c..c6604100e17a16138066aca120c4a074b276e7ce 100644 (file)
@@ -130,8 +130,9 @@ llist_push(struct llist *l,const void *data) {
     }
   }
   /*   fprintf(stderr,"0x%08X\n",l->t); */
-  if (llist_llink_push(l,l->t,data)) { 
-    i_fatal(3, "out of memory\n");
+  if (llist_llink_push(l,l->t,data)) {
+    dIMCTX;
+    im_fatal(aIMCTX, 3, "out of memory\n");
   }
 }
 
index 6f36a0fe928926d9cc79e77a1128cc6b2062cc33..918963ece368c5ed8491c059b5f571404947b7cd 100644 (file)
@@ -972,7 +972,7 @@ i_gradgen(i_img *im, int num, i_img_dim *xo, i_img_dim *yo, i_color *ival, int d
        fdist[p]  = i_max(xd*xd, yd*yd); /* manhattan distance */
        break;
       default:
-       i_fatal(3,"i_gradgen: Unknown distance measure\n");
+       im_fatal(aIMCTX, 3,"i_gradgen: Unknown distance measure\n");
       }
       cs += fdist[p];
     }
@@ -1027,7 +1027,7 @@ i_nearest_color_foo(i_img *im, int num, i_img_dim *xo, i_img_dim *yo, i_color *i
       mindist = i_max(xd*xd, yd*yd); /* manhattan distance */
       break;
     default:
-      i_fatal(3,"i_nearest_color: Unknown distance measure\n");
+      im_fatal(aIMCTX, 3,"i_nearest_color: Unknown distance measure\n");
     }
 
     for(p = 1; p<num; p++) {
@@ -1044,7 +1044,7 @@ i_nearest_color_foo(i_img *im, int num, i_img_dim *xo, i_img_dim *yo, i_color *i
        curdist = i_max(xd*xd, yd*yd); /* manhattan distance */
        break;
       default:
-       i_fatal(3,"i_nearest_color: Unknown distance measure\n");
+       im_fatal(aIMCTX, 3,"i_nearest_color: Unknown distance measure\n");
       }
       if (curdist < mindist) {
        mindist = curdist;
@@ -1189,7 +1189,7 @@ i_nearest_color(i_img *im, int num, i_img_dim *xo, i_img_dim *yo, i_color *oval,
       mindist = i_max(xd*xd, yd*yd); /* manhattan distance */
       break;
     default:
-      i_fatal(3,"i_nearest_color: Unknown distance measure\n");
+      im_fatal(aIMCTX, 3,"i_nearest_color: Unknown distance measure\n");
     }
     
     for(p = 1; p<num; p++) {
@@ -1206,7 +1206,7 @@ i_nearest_color(i_img *im, int num, i_img_dim *xo, i_img_dim *yo, i_color *oval,
        curdist = i_max(xd*xd, yd*yd); /* manhattan distance */
        break;
       default:
-       i_fatal(3,"i_nearest_color: Unknown distance measure\n");
+       im_fatal(aIMCTX, 3,"i_nearest_color: Unknown distance measure\n");
       }
       if (curdist < mindist) {
        mindist = curdist;
index c601c4a29fb093c15177639993c2cfecdec78be3..460a20ff82c5fbb48610a699ab1d06b366b20d3c 100644 (file)
--- a/hlines.c
+++ b/hlines.c
@@ -69,7 +69,8 @@ i_int_init_hlines(
   size_t bytes = count_y * sizeof(i_int_hline_entry *);
 
   if (bytes / count_y != sizeof(i_int_hline_entry *)) {
-    i_fatal(3, "integer overflow calculating memory allocation\n");
+    dIMCTX;
+    im_fatal(aIMCTX, 3, "integer overflow calculating memory allocation\n");
   }
 
   hlines->start_y = start_y;
@@ -112,7 +113,8 @@ i_int_hlines_add(i_int_hlines *hlines, i_img_dim y, i_img_dim x, i_img_dim width
   i_img_dim x_limit = x + width;
 
   if (width < 0) {
-    i_fatal(3, "negative width %d passed to i_int_hlines_add\n", width);
+    dIMCTX;
+    im_fatal(aIMCTX, 3, "negative width %d passed to i_int_hlines_add\n", width);
   }
 
   /* just return if out of range */
diff --git a/image.c b/image.c
index f44391c099c7e4bc58ef8d672bba9581b67b55db..56057e877b436f5fd1ba35fe4549dec619edcfcf 100644 (file)
--- a/image.c
+++ b/image.c
@@ -117,7 +117,7 @@ ICL_new_internal(unsigned char r,unsigned char g,unsigned char b,unsigned char a
 
   im_log((aIMCTX,1,"ICL_new_internal(r %d,g %d,b %d,a %d)\n", r, g, b, a));
 
-  if ( (cl=mymalloc(sizeof(i_color))) == NULL) i_fatal(2,"malloc() error\n");
+  if ( (cl=mymalloc(sizeof(i_color))) == NULL) im_fatal(aIMCTX, 2,"malloc() error\n");
   cl->rgba.r = r;
   cl->rgba.g = g;
   cl->rgba.b = b;
@@ -147,7 +147,7 @@ ICL_set_internal(i_color *cl,unsigned char r,unsigned char g,unsigned char b,uns
   im_log((aIMCTX,1,"ICL_set_internal(cl* %p,r %d,g %d,b %d,a %d)\n",cl,r,g,b,a));
   if (cl == NULL)
     if ( (cl=mymalloc(sizeof(i_color))) == NULL)
-      i_fatal(2,"malloc() error\n");
+      im_fatal(aIMCTX, 2,"malloc() error\n");
   cl->rgba.r=r;
   cl->rgba.g=g;
   cl->rgba.b=b;
@@ -223,7 +223,7 @@ i_fcolor *i_fcolor_new(double r, double g, double b, double a) {
 
   im_log((aIMCTX, 1,"i_fcolor_new(r %g,g %g,b %g,a %g)\n", r, g, b, a));
 
-  if ( (cl=mymalloc(sizeof(i_fcolor))) == NULL) i_fatal(2,"malloc() error\n");
+  if ( (cl=mymalloc(sizeof(i_fcolor))) == NULL) im_fatal(aIMCTX, 2,"malloc() error\n");
   cl->rgba.r = r;
   cl->rgba.g = g;
   cl->rgba.b = b;
diff --git a/img8.c b/img8.c
index 29e9700a0389636ff670fd2e0cd192745e896a6e..373d5a18d8fcfa2fde85cfa4db02866509793180 100644 (file)
--- a/img8.c
+++ b/img8.c
@@ -177,7 +177,7 @@ im_img_empty_ch(pIMCTX, i_img *im,i_img_dim x,i_img_dim y,int ch) {
   im->ch_mask  = MAXINT;
   im->bytes=bytes;
   if ( (im->idata=mymalloc(im->bytes)) == NULL) 
-    i_fatal(2,"malloc() error\n"); 
+    im_fatal(aIMCTX, 2,"malloc() error\n"); 
   memset(im->idata,0,(size_t)im->bytes);
   
   im->ext_data = NULL;