C Language and Libraries Help (clang.hlp) (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
realloc Functions
 Summary Example                         Up Contents Index Back
─────Run-Time Library───────────────────────────────────────────────────────
 
     The realloc family of functions changes the size of a previously
     allocated memory block. The <memblock> argument points to the
     beginning of the memory block. If <memblock> is NULL (_NULLOFF for
     _brealloc), realloc functions in the same way as malloc and
     allocates a new block of <size> bytes. If <memblock> is not NULL
     (_NULLOFF for _brealloc), it should be a pointer returned by a
     prior call to calloc, malloc, or realloc.
 
     The <size> argument gives the new size of the block, in bytes. The
     contents of the block are unchanged up to the shorter of the new
     and old sizes, although the new block may be in a different
     location. Because the new block can be in a new memory location,
     the pointer returned by the realloc functions is not guaranteed to
     be the pointer passed through the <memblock> argument.
 
     If <memblock> is not NULL (_NULLOFF for _brealloc) and <size> is
     0, then the memory pointed to by <memblock> is freed.
 
     In large data models (that is, compact-, large-, and huge-model
     programs), realloc maps to _frealloc. In small data models (tiny-,
     small-, and medium-model programs), realloc maps to _nrealloc.
 
     The various realloc functions reallocate memory in the heaps
     specified below:
 
     Function      Heap
 
     realloc       Depends on data model of the program
     _brealloc     Based heap specified by <seg> value
     _frealloc     Far heap (outside default data segment)
     _nrealloc     Near heap (inside default data segment)
 
     Return Value
 
     The realloc functions return a void pointer to the reallocated
     (and possibly moved) memory block.
 
     The return value is NULL (_NULLOFF for _brealloc) if the size is
     zero and the buffer argument is not NULL (_NULLOFF for
     _brealloc), or if there is not enough available memory to expand
     the block to the given size. In the first case, the original
     block is freed. In the second, the original block is unchanged.
 
     The storage space pointed to by the return value is guaranteed to
     be suitably aligned for storage of any type of object. To get a
     pointer to a type other than void, use a type cast on the return
     value.
                                    -♦-