summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlia Alshanetsky <iliaa@php.net>2003-04-25 00:59:03 +0000
committerIlia Alshanetsky <iliaa@php.net>2003-04-25 00:59:03 +0000
commit1f433956b010002099496a92ecf6050706753ad2 (patch)
treeb0524128e1332100a4a0b0e898875e206649c975
parentd949f9d91272e215f5d1f8c154f37130fd5f8fe4 (diff)
downloadphp-git-1f433956b010002099496a92ecf6050706753ad2.tar.gz
emalloc -> safe_emalloc
-rw-r--r--ext/gd/libgd/gd.c16
-rw-r--r--ext/gd/libgd/gd_png.c12
-rw-r--r--ext/gd/libgd/gd_topal.c12
-rw-r--r--ext/gd/libgd/wbmp.c4
4 files changed, 22 insertions, 22 deletions
diff --git a/ext/gd/libgd/gd.c b/ext/gd/libgd/gd.c
index f2411d6d98..2617ca868c 100644
--- a/ext/gd/libgd/gd.c
+++ b/ext/gd/libgd/gd.c
@@ -125,8 +125,8 @@ gdImagePtr gdImageCreate (int sx, int sy)
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 gdImageCreateTrueColor (int sx, int sy)
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 @@ void gdImageCopyResized (gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int
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 @@ void gdImageFilledPolygon (gdImagePtr im, gdPointPtr p, int n, int c)
}
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 @@ void gdImageSetStyle (gdImagePtr im, int *style, int noOfPixels)
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;
diff --git a/ext/gd/libgd/gd_png.c b/ext/gd/libgd/gd_png.c
index 9e01872f0c..f8d4b1490d 100644
--- a/ext/gd/libgd/gd_png.c
+++ b/ext/gd/libgd/gd_png.c
@@ -216,7 +216,7 @@ gdImagePtr gdImageCreateFromPngCtx (gdIOCtx * infile)
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 @@ gdImagePtr gdImageCreateFromPngCtx (gdIOCtx * infile)
/* 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 @@ void gdImagePngCtxEx (gdImagePtr im, gdIOCtx * outfile, int level)
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 @@ void gdImagePngCtxEx (gdImagePtr im, gdIOCtx * outfile, int level)
} 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) {
diff --git a/ext/gd/libgd/gd_topal.c b/ext/gd/libgd/gd_topal.c
index 77fb4139b2..dfaafe0b44 100644
--- a/ext/gd/libgd/gd_topal.c
+++ b/ext/gd/libgd/gd_topal.c
@@ -758,7 +758,7 @@ select_colors (gdImagePtr im, my_cquantize_ptr cquantize, int desired_colors)
#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 @@ init_error_limit (gdImagePtr im, my_cquantize_ptr cquantize)
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 @@ gdImageTrueColorToPalette (gdImagePtr im, int dither, int colorsWanted)
}
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 @@ gdImageTrueColorToPalette (gdImagePtr im, int dither, int colorsWanted)
}
#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 @@ int gdImageColorMatch (gdImagePtr im1, gdImagePtr im2)
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++) {
diff --git a/ext/gd/libgd/wbmp.c b/ext/gd/libgd/wbmp.c
index 039d80f00c..e115e80b82 100644
--- a/ext/gd/libgd/wbmp.c
+++ b/ext/gd/libgd/wbmp.c
@@ -116,7 +116,7 @@ createwbmp (int width, int height, int color)
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 @@ readwbmp (int (*getin) (void *in), void *in, Wbmp ** return_wbmp)
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);