stdlib malloc Pools

Name

malloc, calloc, free, realloc, mallinfo -- stdlib malloc pool

Synopsis

#include <stdlib.h>
        

void *malloc(size_t size);

void *calloc(size_t nmemb, size_t size);

void free(void *ptr);

void *realloc(void *ptr, size_t size);

struct mallinfo mallinfo(void);

Description

eCos provides the standard library functions used for allocating memory from the heap. malloc() allocates a block of memory of size bytes. calloc() performs the same, but also sets the memory to zero. The function free() returns a block to the pool. realloc resizes a block of memory. Lastly, mallinfo() returns information about the heap, as described by the structure mallinfo:

struct mallinfo {
    int arena;    /* total size of memory arena */
    int ordblks;  /* number of ordinary memory blocks */
    int smblks;   /* number of small memory blocks */
    int hblks;    /* number of mmapped regions */
    int hblkhd;   /* total space in mmapped regions */
    int usmblks;  /* space used by small memory blocks */
    int fsmblks;  /* space available for small memory blocks */
    int uordblks; /* space used by ordinary memory blocks */
    int fordblks; /* space free for ordinary blocks */
    int keepcost; /* top-most, releasable (via malloc_trim) space */
    int maxfree;  /* (NON-STANDARD EXTENSION) size of largest free block */
};