gif.c, bmp.c, font.c and tga.c still need to be checked.
copy_colors_back(hv, &quant);
}
}
- ST(0) = sv_newmortal();
- if (RETVAL == 0) ST(0)=&PL_sv_undef;
- else sv_setiv(ST(0), (IV)RETVAL);
+ ST(0) = sv_newmortal();
+ if (RETVAL == 0) ST(0)=&PL_sv_undef;
+ else sv_setiv(ST(0), (IV)RETVAL);
+ myfree(quant.mc_colors);
+
undef_int
i_writegif_callback(cb, maxbuffer,...)
ival[i] = *(i_color *)SvIV((SV *)SvRV(sv));
}
i_gradgen(im, num, xo, yo, ival, dmeasure);
+ myfree(xo);
+ myfree(yo);
+ myfree(ival);
+
void
i_fountain(im, xa, ya, xb, yb, type, repeat, combine, super_sample, ssample_param, segs)
EXTEND(SP, 1);
PUSHs(sv_2mortal(newSVpv(data, count * sizeof(i_sample_t))));
}
+ myfree(data);
}
else {
if (GIMME_V != G_ARRAY) {
}
}
+
Imager::ImgRaw
i_img_masked_new(targ, mask, x, y, w, h)
Imager::ImgRaw targ
float res[11];
i_img timg;
- mm_log((1,"i_conv(im* 0x%x,coeff 0x%x,len %d)\n",im,coeff,len));
+ mm_log((1,"i_conv(im %p, coeff %p, len %d)\n",im,coeff,len));
i_img_empty_ch(&timg,im->xsize,im->ysize,im->channels);
i_ppix(im,l,i,&rcolor);
}
}
+ i_img_exorcise(&timg);
}
*/
int
-i_convert(i_img *im, i_img *src, float *coeff, int outchan, int inchan)
-{
+i_convert(i_img *im, i_img *src, float *coeff, int outchan, int inchan) {
int x, y;
int i, j;
int ilimit;
i_gpal(src, 0, im->xsize, y, vals);
i_ppal(im, 0, im->xsize, y, vals);
}
+ myfree(vals);
+ myfree(colors);
}
return 1;
/*
- Linked list - stack type
+ Bucketed linked list - stack type
*/
struct llink *
llink_new(struct llink* p,int size) {
struct llink *l;
- l=(struct llink*)mymalloc(sizeof(struct llink));
- l->n=NULL;
- l->p=p;
- l->fill=0;
- l->data=(void*)mymalloc(size);
+ l = mymalloc(sizeof(struct llink));
+ l->n = NULL;
+ l->p = p;
+ l->fill = 0;
+ l->data = mymalloc(size);
return l;
}
int
llist_llink_push(struct llist *lst, struct llink *lnk,void *data) {
int multip;
- multip=lst->multip;
+ multip = lst->multip;
/* fprintf(stderr,"llist_llink_push: data=0x%08X -> 0x%08X\n",data,*(int*)data);
fprintf(stderr,"ssize = %d, multip = %d, fill = %d\n",lst->ssize,lst->multip,lnk->fill); */
struct llist *
llist_new(int multip, int ssize) {
struct llist *l;
- l=(struct llist*)mymalloc(sizeof(struct llist));
- l->h=l->t=NULL;
- l->multip=multip;
- l->ssize=ssize;
- l->count=0;
+ l = mymalloc(sizeof(struct llist));
+ l->h = NULL;
+ l->t = NULL;
+ l->multip = multip;
+ l->ssize = ssize;
+ l->count = 0;
return l;
}
void
llist_push(struct llist *l,void *data) {
- int ssize=l->ssize;
- int multip=l->multip;
+ int ssize = l->ssize;
+ int multip = l->multip;
- /* fprintf(stderr,"llist_push: data=0x%08X\n",data); */
-
- if (l->t == NULL) l->t=l->h=llink_new(NULL,ssize*multip); /* Tail is empty - list is empty */
+ /* fprintf(stderr,"llist_push: data=0x%08X\n",data);
+ fprintf(stderr,"Chain size: %d\n", l->count); */
+
+ if (l->t == NULL) {
+ l->t = l->h = llink_new(NULL,ssize*multip); /* Tail is empty - list is empty */
+ /* fprintf(stderr,"Chain empty - extended\n"); */
+ }
else { /* Check for overflow in current tail */
if (l->t->fill >= l->multip) {
- struct llink* nt=llink_new(l->t,ssize*multip);
+ struct llink* nt = llink_new(l->t, ssize*multip);
l->t->n=nt;
l->t=nt;
/* fprintf(stderr,"Chain extended\n"); */
}
}
/* fprintf(stderr,"0x%08X\n",l->t); */
- if (llist_llink_push(l,l->t,data)) { fprintf(stderr,"DARN!\n"); }
+ if (llist_llink_push(l,l->t,data)) {
+ m_fatal(3, "out of memory\n");
+ }
}
/* returns 0 if the list is empty */
if (l->t == NULL) return 0;
l->t->fill--;
l->count--;
- /* memcpy(data,(char*)(l->t->data)+l->ssize*l->t->fill,l->ssize); */
memcpy(data,(char*)(l->t->data)+l->ssize*l->t->fill,l->ssize);
if (!l->t->fill) { /* This link empty */
- if (l->t->p == NULL) l->h=l->t=NULL; /* and it's the only link */
+ if (l->t->p == NULL) { /* and it's the only link */
+ llink_destroy(l->t);
+ l->h = l->t = NULL;
+ }
else {
l->t=l->t->p;
llink_destroy(l->t->n);
/* dot.info(); */
i_mmarray_render_fill(im,&dot,fill);
+ i_mmarray_dst(&dot);
}
struct stack_element*
crdata(int left,int right,int dadl,int dadr,int y, int dir) {
struct stack_element *ste;
- ste=(struct stack_element*)mymalloc(sizeof(struct stack_element));
- ste->myLx=left;
- ste->myRx=right;
- ste->dadLx=dadl;
- ste->dadRx=dadr;
- ste->myY=y;
- ste->myDirection=dir;
+ ste = mymalloc(sizeof(struct stack_element));
+ ste->myLx = left;
+ ste->myRx = right;
+ ste->dadLx = dadl;
+ ste->dadRx = dadr;
+ ste->myY = y;
+ ste->myDirection = dir;
return ste;
}
/* Macro to create a link and push on to the list */
-#define ST_PUSH(left,right,dadl,dadr,y,dir) { struct stack_element *s=crdata(left,right,dadl,dadr,y,dir); llist_push(st,&s);}
+#define ST_PUSH(left,right,dadl,dadr,y,dir) { struct stack_element *s = crdata(left,right,dadl,dadr,y,dir); llist_push(st,&s); }
/* pops the shadow on TOS into local variables lx,rx,y,direction,dadLx and dadRx */
/* No overflow check! */
-#define ST_POP() { struct stack_element *s; llist_pop(st,&s); lx=s->myLx; rx=s->myRx; dadLx=s->dadLx; dadRx=s->dadRx; y=s->myY; direction=s->myDirection; myfree(s); }
+#define ST_POP() { struct stack_element *s; llist_pop(st,&s); lx = s->myLx; rx = s->myRx; dadLx = s->dadLx; dadRx = s->dadRx; y = s->myY; direction= s->myDirection; myfree(s); }
-#define ST_STACK(dir,dadLx,dadRx,lx,rx,y) { int pushrx=rx+1; int pushlx=lx-1; ST_PUSH(lx,rx,pushlx,pushrx,y+dir,dir); if (rx > dadRx) ST_PUSH(dadRx+1,rx,pushlx,pushrx,y-dir,-dir); if (lx < dadLx) ST_PUSH(lx,dadLx-1,pushlx,pushrx,y-dir,-dir); }
+#define ST_STACK(dir,dadLx,dadRx,lx,rx,y) { int pushrx = rx+1; int pushlx = lx-1; ST_PUSH(lx,rx,pushlx,pushrx,y+dir,dir); if (rx > dadRx) ST_PUSH(dadRx+1,rx,pushlx,pushrx,y-dir,-dir); if (lx < dadLx) ST_PUSH(lx,dadLx-1,pushlx,pushrx,y-dir,-dir); }
#define SET(x,y) btm_set(btm,x,y);
int channels,xsize,ysize;
i_color cval,val;
- channels=im->channels;
- xsize=im->xsize;
- ysize=im->ysize;
+ channels = im->channels;
+ xsize = im->xsize;
+ ysize = im->ysize;
- btm=btm_new(xsize,ysize);
- st=llist_new(100,sizeof(struct stack_element*));
+ btm = btm_new(xsize,ysize);
+ st = llist_new(100,sizeof(struct stack_element*));
/* Get the reference color */
i_gpix(im,seedx,seedy,&val);
/* Find the starting span and fill it */
- lx=i_lspan(im,seedx,seedy,&val);
- rx=i_rspan(im,seedx,seedy,&val);
+ lx = i_lspan(im,seedx,seedy,&val);
+ rx = i_rspan(im,seedx,seedy,&val);
/* printf("span: %d %d \n",lx,rx); */
- for(x=lx;x<=rx;x++) SET(x,seedy);
+ for(x=lx; x<=rx; x++) SET(x,seedy);
- ST_PUSH(lx,rx,lx,rx,seedy+1,1);
- ST_PUSH(lx,rx,lx,rx,seedy-1,-1);
+ ST_PUSH(lx, rx, lx, rx, seedy+1, 1);
+ ST_PUSH(lx, rx, lx, rx, seedy-1,-1);
while(st->count) {
ST_POP();
for(y=bymin;y<=bymax;y++) for(x=bxmin;x<=bxmax;x++) if (btm_test(btm,x,y)) i_ppix(im,x,y,dcol);
btm_destroy(btm);
+ mm_log((1, "DESTROY\n"));
llist_destroy(st);
}
}
i_ppix(im, x, y, &val);
}
+ myfree(fdist);
}
i_plinf(im, 0, im->xsize, y, line);
}
fount_finish_state(&state);
+ if (work) myfree(work);
myfree(line);
}
double matrix[6] = { 1, 0, 0,
0, 1, 0 };
+ mm_log((1, "i_ft2_new(name %p, index %d)\n", name, index));
+
i_clear_error();
error = FT_New_Face(library, name, index, &face);
if (error) {
FT_Glyph_Metrics *gm;
int start = 0;
+ mm_log((1, "i_ft2_bbox(handle %p, cheight %f, cwidth %f, text %p, len %d, bbox %p)\n",
+ handle, cheight, cwidth, text, len, bbox));
+
error = FT_Set_Char_Size(handle->face, cwidth*64, cheight*64,
handle->xdpi, handle->ydpi);
if (error) {
i_color pel;
int loadFlags = FT_LOAD_DEFAULT;
+ mm_log((1, "i_ft2_text(handle %p, im %p, tx %d, ty %d, cl %p, cheight %f, cwidth %f, text %p, len %d, align %d, aa %d)\n",
+ handle, im, tx, ty, cl, cheight, cwidth, text, align, aa));
+
if (vlayout) {
if (!FT_HAS_VERTICAL(handle->face)) {
i_push_error(0, "face has no vertical metrics");
i_color cl, cl2;
int x, y;
+ mm_log((1, "i_ft2_cp(handle %p, im %p, tx %d, ty %d, channel %d, cheight %f, cwidth %f, text %p, len %d, ...)\n",
+ handle, im, tx, ty, channel, cheight, cwidth, text, len));
+
if (vlayout && !FT_HAS_VERTICAL(handle->face)) {
i_push_error(0, "face has no vertical metrics");
return 0;
i_ppix(im, tx + x + bbox[0], ty + y + bbox[1], &cl2);
}
}
-
+ i_img_destroy(work);
return 1;
}
float res[11];
i_img timg;
- mm_log((1,"i_gaussian(im* 0x%x,stdev %.2f)\n",im,stdev));
+ mm_log((1,"i_gaussian(im %p, stdev %.2f)\n",im,stdev));
i_img_empty_ch(&timg,im->xsize,im->ysize,im->channels);
i_ppix(im,l,i,&rcolor);
}
}
+ i_img_exorcise(&timg);
}
Size = GifFile->SWidth * sizeof(GifPixelType);
- GifRow = (GifRowType) mymalloc(Size);
+ GifRow = mymalloc(Size);
for (i = 0; i < GifFile->SWidth; i++) GifRow[i] = GifFile->SBackGroundColor;
myfree(*colour_table);
*colour_table = NULL;
}
+ myfree(GifRow);
i_img_destroy(im);
DGifCloseFile(GifFile);
return NULL;
myfree(*colour_table);
*colour_table = NULL;
}
+ myfree(GifRow);
i_img_destroy(im);
DGifCloseFile(GifFile);
return NULL;
mm_log((1, "Going in with no colormap\n"));
i_push_error(0, "Image does not have a local or a global color map");
/* we can't have allocated a colour table here */
+ myfree(GifRow);
i_img_destroy(im);
DGifCloseFile(GifFile);
return NULL;
myfree(*colour_table);
*colour_table = NULL;
}
+ myfree(GifRow);
i_img_destroy(im);
DGifCloseFile(GifFile);
- return(0);
+ return NULL;
}
if (GifFile->Image.Interlace) {
myfree(*colour_table);
*colour_table = NULL;
}
+ myfree(GifRow);
i_img_destroy(im);
DGifCloseFile(GifFile);
return NULL;
myfree(*colour_table);
*colour_table = NULL;
}
+ myfree(GifRow);
i_img_destroy(im);
DGifCloseFile(GifFile);
return NULL;
myfree(*colour_table);
*colour_table = NULL;
}
+ myfree(GifRow);
i_img_destroy(im);
DGifCloseFile(GifFile);
return NULL;
myfree(*colour_table);
*colour_table = NULL;
}
+ myfree(GifRow);
i_img_destroy(im);
DGifCloseFile(GifFile);
return NULL;
if (match != 1) {
mm_log((1, "myfree_file_line: INCONSISTENT REFCOUNT %d at %s (%i)\n", match, file, line));
+ printf(stderr, "myfree_file_line: INCONSISTENT REFCOUNT %d at %s (%i)\n", match, file, line);
+ exit(255);
}
- mm_log((1, "myfree_file_line: freeing address %p\n", pp-UNDRRNVAL));
+ mm_log((1, "myfree_file_line: freeing address %p (real %p)\n", pp, pp-UNDRRNVAL));
free(pp-UNDRRNVAL);
}
mm_log((1,"wiol_empty_output_buffer(cinfo 0x%p)\n"));
rc = dest->data->writecb(dest->data, dest->buffer, JPGS);
-
+
if (rc != JPGS) { /* XXX: Should raise some jpeg error */
+ myfree(dest->buffer);
mm_log((1, "wiol_empty_output_buffer: Error: nbytes = %d != rc = %d\n", JPGS, rc));
- ERREXIT(cinfo, JERR_FILE_WRITE);
+ ERREXIT(cinfo, JERR_FILE_WRITE);
}
dest->pub.free_in_buffer = JPGS;
dest->pub.next_output_byte = dest->buffer;
size_t nbytes = JPGS - dest->pub.free_in_buffer;
/* yes, this needs to flush the buffer */
/* needs error handling */
+
if (dest->data->writecb(dest->data, dest->buffer, nbytes) != nbytes) {
+ myfree(dest->buffer);
ERREXIT(cinfo, JERR_FILE_WRITE);
}
-
-
- mm_log((1, "wiol_term_destination(cinfo %p)\n", cinfo));
- mm_log((1, "wiol_term_destination: dest %p\n", cinfo->dest));
+
if (dest != NULL) myfree(dest->buffer);
}
*/
i_palidx *quant_translate(i_quantize *quant, i_img *img) {
i_palidx *result;
- mm_log((1, "quant_translate(quant %p, img %p)\n", quant, img));
+ mm_log((1, "quant_translate(quant %p, img %p)\n", quant, img));
- result = mymalloc(img->xsize * img->ysize);
+ result = mymalloc(img->xsize * img->ysize);
switch (quant->translate) {
#ifdef HAVE_LIBGIF
case pt_closest:
translate_closest(quant, img, result);
break;
-
+
case pt_errdiff:
translate_errdiff(quant, img, result);
break;
-
+
case pt_perturb:
default:
translate_addi(quant, img, result);
break;
}
-
+
return result;
}
raw images later */
int line_size = im->xsize * im->channels;
unsigned char *data = mymalloc(line_size);
- if (data) {
- int y = 0;
- rc = line_size;
- while (rc == line_size && y < im->ysize) {
- i_gsamp(im, 0, im->xsize, y, data, NULL, im->channels);
- rc = ig->writecb(ig, data, line_size);
- ++y;
- }
- } else {
- i_push_error(0, "Out of memory");
- return 0;
+
+ int y = 0;
+ rc = line_size;
+ while (rc == line_size && y < im->ysize) {
+ i_gsamp(im, 0, im->xsize, y, data, NULL, im->channels);
+ rc = ig->writecb(ig, data, line_size);
+ ++y;
}
if (rc != line_size) {
i_push_error(errno, "write error");
return 0;
}
+ myfree(data);
} else {
/* paletted image - assumes the caller puts the palette somewhere
else
*/
int line_size = sizeof(i_palidx) * im->xsize;
i_palidx *data = mymalloc(sizeof(i_palidx) * im->xsize);
- if (data) {
- int y = 0;
- rc = line_size;
- while (rc == line_size && y < im->ysize) {
- i_gpal(im, 0, im->xsize, y, data);
- rc = ig->writecb(ig, data, line_size);
- ++y;
- }
- myfree(data);
- } else {
- i_push_error(0, "Out of memory");
- return 0;
+
+ int y = 0;
+ rc = line_size;
+ while (rc == line_size && y < im->ysize) {
+ i_gpal(im, 0, im->xsize, y, data);
+ rc = ig->writecb(ig, data, line_size);
+ ++y;
}
+ myfree(data);
if (rc != line_size) {
i_push_error(errno, "write error");
return 0;
exit(0);
}
-if (!(i_has_format("ft2")) ) { skip(); }
+if (!(i_has_format("ft2")) ) { skip(); }
print "# has ft2\n";
$fontname=$ENV{'TTFONTTEST'}||'./fontfiles/dodge.ttf';
print "# ", Imager->errstr, "\n";
ok(12, Imager->errstr =~ /not enough images/, "didn't get expected error");
+
+
sub ok ($$$) {
my ($num, $test, $desc) = @_;