Function _momAlloc() Foundation
Creates a new memory object and returns its handle.
MomHandle _momAlloc(ULONG size);
This function returns the handle of the created memory object. When not enough memory is available or another error occurs, the value MOM_NULLHANDLE is returned. MOM_NULLHANDLE is never a valid handle of a successfully created memory object.
_momAlloc() is used to create a new memory object. The newly created object always has an even number of bytes, but at least <size> bytes. A new memory object is not automatically assigned a default value. This means that until it is initialized by the programmer, its value is meaningless.
A memory object can not be created when there are no more free handles or not enough memory is available for the object. The cause of a creation error can be checked with _conLastError().
/*
Generate a memory object and initialize with NULLs.
*/
#include "xppcon.h"
MomHandle hNew;
BYTE *pNew;
LONG size = 50;
hNew = _momAlloc(size);
if (hNew != MOM_NULLHANDLE)
{
pNew = _momLock(hNew);
while (size-- > 0)
*pNew++ = 0;
_momUnlock(hNew);
}
else
{
/* ... error handling */
}
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.