sx_MemAlloc

<< Click to Display Table of Contents >>

Navigation:  Apollo API Listing >

sx_MemAlloc

C Declaration

BYTEP FAR PASCAL sx_MemAlloc(LONG lNum);

Description

Allocate Windows global memory. This is a useful function for the C programmer in that it is not necessary to bother with Windows memory handles and constant dereferencing to obtain a usable address.

Note: Memory allocated with sx_MemAlloc must be de-allocated with sx_MemDealloc.

Parameters

lNum: The number of bytes to be allocated. The memory type allocated is Windows Global Fixed and it is initialized to binary zeroes.

Return Value

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

C Example

// create a workarea under the current task

spTask->apWorkItem[i].wpWorkArea =

(WORKAREAP) sx_MemAlloc((LONG) sizeof(WORKAREA));

if (!spTask->apWorkItem[i].wpWorkArea)

return(FALSE);

spTask->apWorkItem[i].uiFileType = (USHORT) iRdeType;

spTask->apWorkItem[i].wpWorkArea->uiArea = (USHORT) i;

See Also

sx_MemDealloc , sx_MemRealloc