cvs: php4(PHP_4_3) /ext/gd/libgd gd.c gd_png.c gd_topal.c wbmp.c
| From: | Ilia Alshanetsky | Date: | Fri, 25 Apr 2003 00:59:03 +0000 |
| Subject: | cvs: php4(PHP_4_3) /ext/gd/libgd gd.c gd_png.c gd_topal.c wbmp.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-20478@lists.php.net to get a copy of this message | ||
iliaa Thu Apr 24 20:59:03 2003 EDT
Modified files: (Branch: PHP_4_3)
/php4/ext/gd/libgd gd.c gd_png.c gd_topal.c wbmp.c
Log:
emalloc -> safe_emalloc
Index: php4/ext/gd/libgd/gd.c
diff -u php4/ext/gd/libgd/gd.c:1.24.2.8 php4/ext/gd/libgd/gd.c:1.24.2.9
--- php4/ext/gd/libgd/gd.c:1.24.2.8 Sat Apr 5 12:24:15 2003
+++ php4/ext/gd/libgd/gd.c Thu Apr 24 20:59:03 2003
@@ -125,8 +125,8 @@
im = (gdImage *) gdMalloc(sizeof(gdImage));
memset(im, 0, sizeof(gdImage));
/* Row-major ever since gd 1.3 */
- im->pixels = (unsigned char **) gdMalloc(sizeof(unsigned char *) * sy);
- im->AA_opacity = (unsigned char **) gdMalloc(sizeof(unsigned char *) * sy);
+ im->pixels = (unsigned char **) safe_emalloc(sizeof(unsigned char *), sy, 0);
+ im->AA_opacity = (unsigned char **) safe_emalloc(sizeof(unsigned char *), sy, 0);
im->polyInts = 0;
im->polyAllocated = 0;
im->brush = 0;
@@ -166,8 +166,8 @@
gdImagePtr im;
im = (gdImage *) gdMalloc(sizeof(gdImage));
memset(im, 0, sizeof(gdImage));
- im->tpixels = (int **) gdMalloc(sizeof(int *) * sy);
- im->AA_opacity = (unsigned char **) gdMalloc(sizeof(unsigned char *) * sy);
+ im->tpixels = (int **) safe_emalloc(sizeof(int *), sy, 0);
+ im->AA_opacity = (unsigned char **) safe_emalloc(sizeof(unsigned char *), sy, 0);
im->polyInts = 0;
im->polyAllocated = 0;
im->brush = 0;
@@ -2146,8 +2146,8 @@
int *stx, *sty;
/* We only need to use floating point to determine the correct stretch vector for one line's
worth. */
double accum;
- stx = (int *) gdMalloc (sizeof (int) * srcW);
- sty = (int *) gdMalloc (sizeof (int) * srcH);
+ stx = (int *) safe_emalloc(sizeof(int), srcW, 0);
+ sty = (int *) safe_emalloc(sizeof(int), srcH, 0);
accum = 0;
for (i = 0; (i < srcW); i++) {
@@ -2854,7 +2854,7 @@
}
if (!im->polyAllocated) {
- im->polyInts = (int *) gdMalloc(sizeof(int) * n);
+ im->polyInts = (int *) safe_emalloc(sizeof(int), n, 0);
im->polyAllocated = n;
}
if (im->polyAllocated < n) {
@@ -2933,7 +2933,7 @@
if (im->style) {
gdFree(im->style);
}
- im->style = (int *) gdMalloc(sizeof(int) * noOfPixels);
+ im->style = (int *) safe_emalloc(sizeof(int), noOfPixels, 0);
memcpy(im->style, style, sizeof(int) * noOfPixels);
im->styleLength = noOfPixels;
im->stylePos = 0;
Index: php4/ext/gd/libgd/gd_png.c
diff -u php4/ext/gd/libgd/gd_png.c:1.4.2.3 php4/ext/gd/libgd/gd_png.c:1.4.2.4
--- php4/ext/gd/libgd/gd_png.c:1.4.2.3 Sat Apr 5 12:24:16 2003
+++ php4/ext/gd/libgd/gd_png.c Thu Apr 24 20:59:03 2003
@@ -216,7 +216,7 @@
case PNG_COLOR_TYPE_GRAY:
case PNG_COLOR_TYPE_GRAY_ALPHA:
/* create a fake palette and check for single-shade transparency */
- if ((palette = (png_colorp) gdMalloc (256 * sizeof (png_color))) == NULL) {
+ if ((palette = (png_colorp) safe_emalloc(256, sizeof(png_color), 0)) == NULL) {
php_gd_error("gd-png error: cannot allocate gray palette\n");
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
@@ -281,9 +281,9 @@
/* allocate space for the PNG image data */
rowbytes = png_get_rowbytes(png_ptr, info_ptr);
- image_data = (png_bytep) gdMalloc (rowbytes * height);
+ image_data = (png_bytep) safe_emalloc(rowbytes, height, 0);
- row_pointers = (png_bytepp) gdMalloc (height * sizeof (png_bytep));
+ row_pointers = (png_bytepp) safe_emalloc(height, sizeof (png_bytep), 0);
/* set the individual row_pointers to point at the correct offsets */
for (h = 0; h < height; ++h) {
@@ -625,10 +625,10 @@
int channels = im->saveAlphaFlag ? 4 : 3;
/* Our little 7-bit alpha channel trick costs us a bit here. */
png_bytep *row_pointers;
- row_pointers = gdMalloc(sizeof (png_bytep) * height);
+ row_pointers = safe_emalloc(sizeof(png_bytep), height, 0);
for (j = 0; j < height; ++j) {
int bo = 0;
- row_pointers[j] = (png_bytep) gdMalloc(width * channels);
+ row_pointers[j] = (png_bytep) safe_emalloc(width, channels, 0);
for (i = 0; i < width; ++i) {
unsigned char a;
row_pointers[j][bo++] = gdTrueColorGetRed(im->tpixels[j][i]);
@@ -659,7 +659,7 @@
} else {
if (remap) {
png_bytep *row_pointers;
- row_pointers = gdMalloc(sizeof (png_bytep) * height);
+ row_pointers = safe_emalloc(sizeof(png_bytep), height, 0);
for (j = 0; j < height; ++j) {
row_pointers[j] = (png_bytep) gdMalloc(width);
for (i = 0; i < width; ++i) {
Index: php4/ext/gd/libgd/gd_topal.c
diff -u php4/ext/gd/libgd/gd_topal.c:1.8.2.3 php4/ext/gd/libgd/gd_topal.c:1.8.2.4
--- php4/ext/gd/libgd/gd_topal.c:1.8.2.3 Sat Apr 5 12:24:16 2003
+++ php4/ext/gd/libgd/gd_topal.c Thu Apr 24 20:59:03 2003
@@ -758,7 +758,7 @@
#ifdef ORIGINAL_LIB_JPEG
boxlist = (boxptr) (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
desired_colors * SIZEOF (box));
#else
- boxlist = (boxptr) gdMalloc (desired_colors * sizeof (box));
+ boxlist = (boxptr) safe_emalloc(desired_colors, sizeof(box), 0);
#endif
/* Initialize one box containing whole space */
numboxes = 1;
@@ -1511,7 +1511,7 @@
my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
table = (int *) (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE *
2 + 1) * SIZEOF (int));
#else
- cquantize->error_limiter_storage = (int *) gdMalloc ((MAXJSAMPLE * 2 + 1) * sizeof (int));
+ cquantize->error_limiter_storage = (int *) safe_emalloc((MAXJSAMPLE * 2 + 1), sizeof(int), 0);
if (!cquantize->error_limiter_storage) {
return;
}
@@ -1712,9 +1712,9 @@
}
cquantize->needs_zeroed = TRUE; /* histogram is garbage now */
#else
- cquantize->histogram = (hist3d) gdMalloc (HIST_C0_ELEMS * sizeof (hist2d));
+ cquantize->histogram = (hist3d) safe_emalloc(HIST_C0_ELEMS, sizeof(hist2d), 0);
for (i = 0; i < HIST_C0_ELEMS; i++) {
- cquantize->histogram[i] = (hist2d) gdMalloc(HIST_C1_ELEMS * HIST_C2_ELEMS * sizeof
(histcell));
+ cquantize->histogram[i] = (hist2d) safe_emalloc((HIST_C1_ELEMS * HIST_C2_ELEMS),
sizeof(histcell), 0);
}
#endif
@@ -1758,7 +1758,7 @@
}
#else
- cquantize->fserrors = (FSERRPTR) gdMalloc(3 * sizeof (FSERROR));
+ cquantize->fserrors = (FSERRPTR) gdMalloc(3 * sizeof(FSERROR));
init_error_limit (im, cquantize);
arraysize = (size_t) ((im->sx + 2) * (3 * sizeof (FSERROR)));
gdFree(cquantize->fserrors);
@@ -1884,7 +1884,7 @@
return -3; /* the images are meant to be the same dimensions */
}
- buf = (unsigned long *)gdMalloc( sizeof(unsigned long) * 5 * im2->colorsTotal );
+ buf = (unsigned long *)safe_emalloc(sizeof(unsigned long), (5 * im2->colorsTotal), 0);
memset( buf, 0, sizeof(unsigned long) * 5 * im2->colorsTotal );
for (x=0; x<im1->sx; x++) {
Index: php4/ext/gd/libgd/wbmp.c
diff -u php4/ext/gd/libgd/wbmp.c:1.2 php4/ext/gd/libgd/wbmp.c:1.2.4.1
--- php4/ext/gd/libgd/wbmp.c:1.2 Sun Aug 11 09:50:27 2002
+++ php4/ext/gd/libgd/wbmp.c Thu Apr 24 20:59:03 2003
@@ -116,7 +116,7 @@
if ((wbmp = (Wbmp *) gdMalloc (sizeof (Wbmp))) == NULL)
return (NULL);
- if ((wbmp->bitmap = (int *) gdMalloc (sizeof (int) * width * height)) == NULL)
+ if ((wbmp->bitmap = (int *) safe_emalloc(sizeof(int), (width * height), 0)) == NULL)
{
gdFree (wbmp);
return (NULL);
@@ -176,7 +176,7 @@
printf ("W: %d, H: %d\n", wbmp->width, wbmp->height);
#endif
- if ((wbmp->bitmap = (int *) gdMalloc (sizeof (int) * wbmp->width * wbmp->height)) ==
NULL)
+ if ((wbmp->bitmap = (int *) safe_emalloc(sizeof(int), (wbmp->width * wbmp->height), 0))
== NULL)
{
gdFree (wbmp);
return (-1);