prg_mem_realloc()
Abstract
Re-allocates an existing block of general-purpose memory with a new size.
Syntax
prg_mem_realloc (mem_ptr, size)
| Argument | Type | Description |
|---|---|---|
mem_ptr |
void * |
The existing memory block to be re-allocated. |
size |
size_t |
Number of bytes requested for the memory re-allocation. |
Return Type
void *
Pointer to the re-allocated block of memory. PRGC_NIL is returned if the memory re-allocation fails.
Header
prg_mem_funcs.h
Example
/* re-allocate a document request message */
doc_req_msg = (Doc_Req_Msg *) prg_mem_realloc (doc_req_msg,
sizeof (Big_Doc_Req_Msg));
Details
If no memory block is specified (mem_ptr is PRGC_NIL), this function acts like prg_mem_alloc().
If size is bigger than the previously allocated memory block, the existing memory contents are unchanged and the additional space is filled with zeros.
Purpose
Provides a mechanism to dynamically re-allocate memory with a new size. This function is similar to the realloc() function.
Errors
- Recoverable Error: Request to allocate (<size> bytes) of Prg memory failed.
Reference
- use
prg_mem_free()to deallocate a previously allocated block of memory - use
prg_mem_copy()to copy a block of memory - use
prg_mem_alloc_dont_clear()to allocate a block of memory without clearing it