// Grows a ntry table for a MLU. Each time this function is called, table size is multiplied times two. static cmsBool GrowMLUtable(cmsMLU* mlu) { int AllocatedEntries; _cmsMLUentry *NewPtr; // Sanity check if (mlu == NULL) return FALSE; AllocatedEntries = mlu ->AllocatedEntries * 2; // Check for overflow if (AllocatedEntries / 2 != mlu ->AllocatedEntries) return FALSE; // Reallocate the memory NewPtr = (_cmsMLUentry*)_cmsRealloc(mlu ->ContextID, mlu ->Entries, AllocatedEntries*sizeof(_cmsMLUentry)); if (NewPtr == NULL) return FALSE; mlu ->Entries = NewPtr; mlu ->AllocatedEntries = AllocatedEntries; return TRUE; }
// Grow the list to keep at least NumElements static cmsBool GrowNamedColorList(cmsNAMEDCOLORLIST* v) { cmsUInt32Number size; _cmsNAMEDCOLOR * NewPtr; if (v == NULL) return FALSE; if (v ->Allocated == 0) size = 64; // Initial guess else size = v ->Allocated * 2; // Keep a maximum color lists can grow, 100K entries seems reasonable if (size > 1024*100) return FALSE; NewPtr = (_cmsNAMEDCOLOR*) _cmsRealloc(v ->ContextID, v ->List, size * sizeof(_cmsNAMEDCOLOR)); if (NewPtr == NULL) return FALSE; v ->List = NewPtr; v ->Allocated = size; return TRUE; }