Function _momUnlock() Foundation
Ends access to a memory object.
XPPAPIRET _momUnlock(MomHandle mhObj);
Always returns NULL.
_momUnlock() is used to end access to a memory object. This function should be called as soon as the pointer to the object's data (returned by _momLock()) is no longer needed.
The unlock should always take place before the end of the function which has locked the object. Locking a memory object over a longer time span is not illegal, but should be avoided. The more objects are locked in memory the less efficient is the packing of memory, which causes fragmentation.
/*
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;
/* Warning: after the following call the value pNew is invalid */
_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.