Reallocate memory.
CS_VOID* srv_realloc(mp,newsize)
CS_VOID *mp; CS_INT newsize;
A pointer to the old block of memory.
The number of bytes to reallocate.
Returns |
To indicate |
---|---|
A pointer to the newly allocated space |
The location of the new space. |
A null pointer |
Server-Library could not allocate newsize bytes. |
#include <ospublic.h>
/*
** Local Prototype.
*/
extern CS_RETCODE ex_srv_realloc PROTOTYPE((
CS_VOID *mp,
CS_INT newsize
));
/*
** EX_SRV_REALLOC
**
** Reallocate a memory chunk.
**
** Arguments:
** mp A pointer to existing memory block.
** newsize The new size of the memory block.
**
** Returns:
** CS_SUCCEED Memory was allocated successfully.
** CS_FAIL An error was detected.
*/
CS_RETCODE ex_srv_realloc(mp, newsize)
CS_VOID *mp;
CS_INT newsize;
{
mp = srv_realloc(mp, newsize);
if(mp == (CS_VOID *)NULL)
{
return(CS_FAIL);
}
return(CS_SUCCEED);
}
srv_realloc reallocates memory dynamically.
It changes the size of the block referenced by mp to newsize, and returns a pointer to the (possibly moved) block.
Any memory allocated using srv_realloc should be freed by calling srv_free.
Use srv_realloc wherever the standard C memory-allocation routines would be used.
Currently, srv_realloc calls the C routine, realloc. An Open Server application, however, can install its own memory management routines using the srv_props routine. The parameter-passing conventions of the user-installed routines must be the same as those of realloc. If the application is not configured to use the user-installed routines, Open Server will call realloc.