_SetHandSize( ) API Library Routine
Changes the amount of memory allocated to the memory block handle hand.
unsigned short _SetHandSize(MHANDLE hand, unsigned long size)
MHANDLE hand; /* Memory block handle. */
unsigned int size; /* New number of bytes. */
Remarks
_SetHandSize( ) returns True (an integer other than 0) if the reallocation is successful, or False (0) if the reallocation fails. The data associated with the MHANDLE is preserved. If hand is a locked MHANDLE, _SetHandSize( ) fails.
For more information on how to create an API library and integrate it with Visual FoxPro, see Accessing the Visual FoxPro API.
Example
The following example uses _SetHandSize( ) to change the amount of memory allocated to an MHANDLE.
Visual FoxPro Code
SET LIBRARY TO SETHANDS
= HANDTOPTR("Hello, world.") && displays "Hello, world" on screen
C Code
#include <pro_ext.h>
void NullTerminate(Value FAR *cVal)
{
if (!_SetHandSize(cVal->ev_handle, cVal->ev_length + 1))
{
_Error(182); // "Insufficient memory"
}
((char FAR *) _HandToPtr(cVal->ev_handle))[cVal->ev_length] = '\0';
}
FAR Example(ParamBlk FAR *parm)
{
NullTerminate(&parm->p[0].val);
_HLock(parm->p[0].val.ev_handle);
_PutStr(_HandToPtr(parm->p[0].val.ev_handle));
_HUnLock(parm->p[0].val.ev_handle);
}
FoxInfo myFoxInfo[] = {
{"HANDTOPTR", (FPFI) Example, 1, "C"},
};
FoxTable _FoxTable = {
(FoxTable FAR *) 0, sizeof(myFoxInfo)/sizeof(FoxInfo), myFoxInfo
};
See Also
_AllocHand( ) API Library Routine | _FreeHand( ) API Library Routine | _GetHandSize( ) API Library Routine | _HandToPtr( ) API Library Routine | _HLock( ) API Library Routine | _HUnLock( ) API Library Routine | _MemAvail( ) API Library Routine