KCMS CMM Reference Manual


This example shows you how to change the size of memory with the KcsMemoryBlock class.

Example 2-2 Resizing Memory with KcsMemoryBlock

KcsStatus resizeIt()
 	unsigned long sNewSize = 10;
 	KcsStatus sStatus;
 	KcsMemoryBlock *memBlock;
 	char * buffer = {`a','b','c','d'};

 	// create a new KcsMemoryBlock object
 	memBlock = new KcsMemoryBlock(&sStatus,4);
 	if (sStatus != KCS_SUCCESS)
 			return (sStatus);
 	// put the four bytes above into the new KcsMemoryBlock
 	sStatus = memBlock->put(buffer,4);
 	if (sStatus != KCS_SUCCESS)
 			return (sStatus);
 	// resize the KcsMemoryBlock from 4 to 10	
 	sStatus = memBlock->reSize(sNewSize);
 	//Finished with the data
 	delete memBlock;
 	return (sStatus);