Keil Logo


#include <stdlib.h>

void *malloc (
  unsigned int size);   /* block size to allocate */

The malloc function allocates a memory block from the memory pool of size bytes in length.


  • 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 malloc function returns a pointer to the allocated block or a null pointer if there is not enough memory to satisfy the allocation request.

See Also

calloc, free, init_mempool, realloc

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

void tst_malloc (void) {
  unsigned char *p;

  p = malloc (1000); /* allocate 1000 bytes */

  if (p == 0)
    printf ("Not enough memory space\n");
    printf ("Memory allocated\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.