sx_MemRealloc

<< Click to Display Table of Contents >>

Navigation:  Apollo API Listing >

sx_MemRealloc

C Declaration

BYTEP FAR PASCAL sx_MemRealloc

(VOIDP vpPtr,

LONG lSize);

Description

Change the size of a memory block allocated with sx_MemAlloc.

 

Parameters

vpPtr: A pointer to memory that was returned by sx_MemAlloc or sx_MemRealloc.

lSize: The new size of the memory block.

Return Value

A BYTEP (char far *) to the allocated memory. Always test for a NULL value, which indicates that the reallocation has failed.

C Example

cpTextBuffer = (BYTEP) sx_MemAlloc((LONG) MAXMEMO);

if (!cpTextBuffer)

goto sxrexit;

 

// read the memo

uiMemoLen = GetMemo(wpWorkArea, BASEPTR->lRecNum, lMemoNum,

cpTextBuffer, (USHORT) MAXMEMO);

if (!uiMemoLen)

{

sx_MemDealloc(cpTextBuffer);

goto sxrexit;

}

 

// reallocate mem back to actual memo size

cpTextBuffer = sx_MemRealloc(cpTextBuffer, (LONG) uiMemoLen + 1);

if (!cpTextBuffer)

goto sxrexit;

See Also

sx_MemAlloc, sx_MemDealloc