Function _momFree() Foundation
Releases a memory object.
XPPAPIRET _momFree(MomHandle hOld);
The return value is always 0.
_momFree() should always be called when a memory object is no longer needed. If this does not happen the memory object remains allocated until the end of the Xbase++ program, since no garbage collection is performed for memory objects created with _momAlloc().
Important:
The handle which is passed to _momFree() must belong to an object created with _momAlloc() and not yet released. If this is not the case, a fatal error is generated and the application terminates. When calling _momFree(), the memory object must not be locked by the thread making the call, since _momFree() would wait endlessly for the unlock. If the memory object is locked by a different thread, _momFree() waits until _momUnlock() is called by that thread and then releases the object.
/*
Creation and release of a temporary buffer
*/
#include "xppcon.h"
MomHandle hNew;
BYTE *pNew;
LONG size = 50;
hNew = _momAlloc(size);
if (hNew != MOM_NULLHANDLE)
{
pNew = _momLock(hNew);
/*
... operations on the memory object
*/
_momUnlock(hNew);
_momFree(hNew);
}
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.