Keil Logo

free

Summary
#include <stdlib.h>

void free (
  void *p);      /* block to free */
Description

The free function returns a memory block to the memory pool. The p argument points to a memory block that was previously allocated with the calloc, malloc, or realloc functions. Once it has been returned to the memory pool by the free function, the block is available for subsequent allocation.

If p is a null pointer, it is ignored.

Note

  • 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

None.

See Also

calloc, init_mempool, malloc, realloc

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

void tst_free (void) {
  unsigned char *mbuf;

  printf ("Allocating memory\n");
  mbuf = malloc (1000);

  if (mbuf == 0) {
    printf ("Unable to allocate memory\n");
  }

  else {
    free (mbuf);
    printf ("Memory free\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.