Branch: Tag:

2004-05-19

2004-05-19 00:10:11 by Martin Nilsson <mani@lysator.liu.se>

Some malloc fixes

Rev: src/modules/Image/blit.c:1.57
Rev: src/modules/Image/colortable.c:1.120
Rev: src/modules/Image/dct.c:1.27
Rev: src/modules/Image/encodings/atari.c:1.4
Rev: src/modules/Image/encodings/atari.h:1.4
Rev: src/modules/Image/encodings/neo.c:1.10
Rev: src/modules/Image/encodings/pcx.c:1.22
Rev: src/modules/Image/encodings/png.c:1.64
Rev: src/modules/Image/encodings/tga.c:1.36
Rev: src/modules/Image/encodings/wbf.c:1.16
Rev: src/modules/Image/encodings/x.c:1.46
Rev: src/modules/Image/encodings/xcf.c:1.49
Rev: src/modules/Image/font.c:1.84
Rev: src/modules/Image/image.c:1.215
Rev: src/modules/Image/matrix.c:1.49
Rev: src/modules/Image/pattern.c:1.30
Rev: src/modules/Image/polyfill.c:1.49
Rev: src/modules/Image/search.c:1.29

2:   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: blit.c,v 1.56 2004/03/05 23:04:02 nilsson Exp $ + || $Id: blit.c,v 1.57 2004/05/19 00:10:10 nilsson Exp $   */      #include "global.h"
215:    if (x1>x2) tmp=x1, x1=x2, x2=tmp;    if (y1>y2) tmp=y1, y1=y2, y2=tmp;    +  new=xalloc( (x2-x1+1)*(y2-y1+1)*sizeof(rgb_group) + 1); +     if (x1==0 && y1==0 &&    img->xsize-1==x2 && img->ysize-1==y2)    {    *dest=*img; -  new=malloc( (x2-x1+1)*(y2-y1+1)*sizeof(rgb_group) + 1); -  if (!new) -  resource_error(NULL,0,0,"memory",0,"Out of memory.\n"); +     THREADS_ALLOW();    MEMCPY(new,img->img,(x2-x1+1)*(y2-y1+1)*sizeof(rgb_group));    THREADS_DISALLOW();
229:    return;    }    -  new=malloc( (x2-x1+1)*(y2-y1+1)*sizeof(rgb_group) +1); -  if (!new) -  resource_error(NULL,0,0,"memory",0,"Out of memory.\n"); -  +     img_clear(new,THIS->rgb,(x2-x1+1)*(y2-y1+1));       dest->xsize=x2-x1+1;
264:   void img_clone(struct image *newimg,struct image *img)   {    if (newimg->img) free(newimg->img); -  newimg->img=malloc(sizeof(rgb_group)*img->xsize*img->ysize +1); -  if (!newimg->img) resource_error(NULL,0,0,"memory",0,"Out of memory.\n"); +  newimg->img=xalloc(sizeof(rgb_group)*img->xsize*img->ysize +1);    THREADS_ALLOW();    MEMCPY(newimg->img,img->img,sizeof(rgb_group)*img->xsize*img->ysize);    THREADS_DISALLOW();