Re: [PHP4BETA] dynamic allocation in ImagePolygon

From: Date: Mon, 01 May 2000 20:03:34 +0000
Subject: Re: [PHP4BETA] dynamic allocation in ImagePolygon
References: 1  Groups: php.version4 
Request: Send a blank email to php-version4+get-14286@lists.php.net to get a copy of this message
Good idea. Applied to both PHP 3 and 4. -Rasmus > --- gd.c.orig Sun Apr 30 23:58:27 2000 > +++ gd.c Mon May 1 13:17:59 2000 > @@ -173,8 +173,6 @@ > #endif > > > -#define PolyMaxPoints 256 > - > static void php_free_gd_font(gdFontPtr fp) > { > if (fp->data) { > @@ -1395,7 +1393,7 @@ > zval **IM, **POINTS, **NPOINTS, **COL; > pval **var = NULL; > gdImagePtr im; > - gdPoint points[PolyMaxPoints]; > + gdPointPtr points; > int npoints, col, nelem, i; > GDLS_FETCH(); > > @@ -1441,8 +1439,9 @@ > RETURN_FALSE; > } > > - if (npoints > PolyMaxPoints) { > - php_error(E_WARNING, "maximum %d points", PolyMaxPoints); > + points = (gdPointPtr) emalloc(npoints * sizeof(gdPoint)); > + if (points == NULL) { > + php_error(E_WARNING, "ImagePolygon: Memory allocation fault"); > RETURN_FALSE; > } > > @@ -1465,6 +1464,8 @@ > else { > gdImagePolygon(im, points, npoints, col); > } > + > + efree(points); > > RETURN_TRUE; > } > > > > > ------------------------------------------------------------------------------ > Marc Pohl, Service-Center-Infrastruktur, Westdeutscher Rundfunk, D-50600 Koeln > marc.pohl@wdr.de, +49 221 220 8618, http://www.wdr.de/ > ------------------------------------------------------------------------------ > > >

« previous php.version4 (#14286) next »