/* Add a command to the DL table - pen up or pen down coordinates. Resizing the table as appropriate. */ static int hpgl_add_dl_char_data(hpgl_state_t * pgls, hpgl_dl_cdata_t * pcdata, short cc_data) { /* characters stored as short */ int csz = sizeof(short); if (pcdata->index == -1) { /* first element - allocate a small array which will be resized as needed */ pcdata->data = (short *)gs_alloc_bytes(pgls->memory, 2 * csz, "DL data"); if (pcdata->data == 0) return e_Memory; } else if (gs_object_size(pgls->memory, pcdata->data) == (pcdata->index + 1) * csz) { /* new character doesn't fit - double the size of the array */ short *new_cdata = (short *)gs_resize_object(pgls->memory, pcdata->data, (pcdata->index + 1) * csz * 2, "DL data resize"); if (new_cdata == 0) { return e_Memory; } pcdata->data = new_cdata; } pcdata->data[++pcdata->index] = cc_data; return 0; }
static void *gs_lcms2_realloc(cmsContext id, void *ptr, unsigned int size) { gs_memory_t *mem = (gs_memory_t *)id; void *ptr2; if (ptr == 0) return gs_lcms2_malloc(id, size); if (size == 0) { gs_lcms2_free(id, ptr); return NULL; } #if defined(SHARE_LCMS) && SHARE_LCMS==1 ptr2 = realloc(ptr, size); #else ptr2 = gs_resize_object(mem, ptr, size, "lcms"); #endif #if DEBUG_LCMS_MEM gs_warn3("lcms realloc (%x,%d) at 0x%x",ptr,size,ptr2); #endif return ptr2; }
static byte * nogc_resize_string(gs_memory_t * mem, byte * data, uint old_num, uint new_num, client_name_t cname) { return gs_resize_object(mem, data, new_num, cname); }