CARM User's Guide

Discontinued

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");
  }
}