Keil Logo


#include <stdlib.h>

void *realloc (
  void *p,              /* previously allocated block */
  unsigned int size);   /* new size for block */

The realloc function changes the size of a previously allocated memory block. The p argument points to the allocated block and size specifies the new size for the block. The contents of the existing block are copied to the new block. Any additional area in the new block, due to a larger block size, is not initialized.


  • Source code for this routine is provide in the LIB folder. You may modify the source to customize this function for your particular hardware environment.
Return Value

The realloc function returns a pointer to the new block. If there is not enough memory in the memory pool to satisfy the memory request, a null pointer is returned and the original memory block is not affected.

See Also

calloc, free, init_mempool, malloc

#include <stdlib.h>
#include <stdio.h> /* for printf */

void tst_realloc (void) {
  void *p;
  void *new_p;

  p = malloc (100);

  if (p != 0) {
    new_p = realloc (p, 200);

    if (new_p != 0)
      p = new_p;
      printf ("Reallocation failed\n");

Related Knowledgebase Articles

  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.