Ejemplo n.º 1
0
void ArraySet(ArrayStore *theArray, uint index, uint value)
{
	int bytesToClear;
	char *clearMem;

	if (!theArray->array)
		return;

	if (index >= theArray->size)
	{
		int newsize = index + ARRAY_BLOCK_CHUNK;
	
		theArray->array = (void *) ReallocPtr((char *) theArray->array,  theArray->type * newsize);

		if (!theArray->array)
			Error(Error_Fatal, "ArrayClass failed to reallocate 4");

		// Clear out new memory

		bytesToClear = (newsize - theArray->size) * theArray->type;
		clearMem = (char *) theArray->array + (theArray->size * theArray->type);
		memset(clearMem, 0, bytesToClear);

		// Set the new size

		theArray->size = newsize;	
	}

	switch(theArray->type)
	{
		case 1:
			((uchar *)theArray->array)[index] = value;
		break;

		case 2:
			((ushort *)theArray->array)[index] = value;
		break;

		case 4:
		{
			//int *tab = theArray->array;
			((uint *)theArray->array)[index] = value;
		}
		break;
	}
	
	if (index > theArray->hi)
		theArray->hi = index;

	if (index < theArray->lo)
		theArray->lo = index;
}
Ejemplo n.º 2
0
void * ArrayPtr(ArrayStore *theArray, uint index)
{
	int bytesToClear;
	char *clearMem;
	char *arrayPtr;
	
	if (!theArray->array)
		return 0;

	if (index >= theArray->size)
	{
		int newsize = index + ARRAY_BLOCK_CHUNK;
	
		theArray->array = (void *) ReallocPtr((char *) theArray->array,  theArray->type * newsize);

		if (!theArray->array)
			Error(Error_Fatal, "ArrayClass failed to reallocate 2");

		// Clear out new memory

		bytesToClear = (newsize - theArray->size) * theArray->type;
		clearMem = (char *) theArray->array + (theArray->size * theArray->type);
		memset(clearMem, 0, bytesToClear);

		// Set the new size

		theArray->size = newsize;	
	}

	if (index > theArray->hi)
		theArray->hi = index;

	if (index < theArray->lo)
		theArray->lo = index;

	arrayPtr = (char *) theArray->array + (theArray->type * index);
	return (void *) arrayPtr;
}
Ejemplo n.º 3
0
// Generic reallocate
void* CMSEXPORT _cmsRealloc(cmsContext ContextID, void* Ptr, cmsUInt32Number size)
{
    return ReallocPtr(ContextID, Ptr, size);
}