Function _momResize() Foundation

Changes the size of a memory object.

Syntax
XPPAPIRET _momResize(MomHandle mhObj, ULONG size);
Parameters
MomHandle mhObj
Handle of the memory object whose size is to be changed.
ULONG size
Desired size of the memory object in bytes.
Return

Returns NULL when the size is successfully changed. Otherwise an error value is returned and the memory object retins its old size.

Description

_momResize() is used to change the size of a memory object created with _momAlloc(). If the object is enlarged the previous content will be remained. The bytes added at the end of the object are not initialized. If the object is reduced in size, data bytes at the end of the object are truncated. The remainder of the content is unchanged.

Do not pass a handle to a memory object that is already locked.

Examples
/* 
   Create a memory object, then change its size 
*/ 
#include "xppcon.h" 

MomHandle hNew; 


hNew = _momAlloc(10); 
if (hNew != MOM_NULLHANDLE) 
{ 
   if (_momResize(hNew, 20) == 0) 
   { 
      /* ... operations with hNew */ 
   } 
   else 
   { 
      /* ... error handling */ 
   } 
   _momFree(hNew); 
} 
else 
{ 
   /* ... error handling */ 
} 

Feedback

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.