/* grow (or shrink) dynamic pointer */ static int gdReallocDynamic (dynamicPtr * dp, int required) { void *newPtr; /* First try gdRealloc(). If that doesn't work, make a new memory block and copy. */ if ((newPtr = gdRealloc (dp->data, required))) { dp->realSize = required; dp->data = newPtr; return TRUE; } /* create a new pointer */ newPtr = gdMalloc (required); if (!newPtr) { dp->dataGood = FALSE; return FALSE; } /* copy the old data into it */ memcpy (newPtr, dp->data, dp->logicalSize); gdFree (dp->data); dp->data = newPtr; dp->realSize = required; return TRUE; }
void gdClipSetAdd(gdImagePtr im,gdClipRectanglePtr rect) { gdClipRectanglePtr more; if (im->clip == 0) { im->clip = gdMalloc (sizeof (gdClipSet)); if (im->clip == 0) return; im->clip->max = 8; im->clip->count = 0; im->clip->list = gdMalloc (im->clip->max * sizeof (gdClipRectangle)); if (im->clip->list == 0) { gdFree (im->clip); im->clip = 0; return; } } if (im->clip->count == im->clip->max) { more = gdRealloc (im->clip->list,(im->clip->max + 8) * sizeof (gdClipRectangle)); if (more == 0) return; im->clip->max += 8; } im->clip->list[im->clip->count] = (*rect); im->clip->count++; }