NXMemRealloc

Changes the size of an allocated memory block.

Library:LibC
Classification:NKS
Service:Memory Management

Syntax

  #include <nks/memory.h>
   
  void *NXMemRealloc (
     void    *old,
     size_t   newSize,
     size_t   alignment);
  

Parameters

old

(IN) Points to the original block of memory.

newSize

(IN) Specifies the total size of the memory to be reallocated.

alignment

(IN) Specifies the alignment requirements, if any. Zero indicates a default alignment. If a nonzero alignment value is specified, it must be a power of two. If an illegal alignment is specified, the alignment reverts to default alignment.

Return Values

If successful, returns a pointer to the block of allocated memory; otherwise returns NULL.

If the original block was larger than the new requested size, the same block might be returned. If a smaller size block is returned, as much data as possible from the old block is preserved.

Remarks

If the request requires a new allocation, the data held in the original block is transferred into the newly allocated block. The unused bytes are not zero filled.

See Also

NXMemAlloc