--- title: mmmalloc related: - "[thread_pool](thread_pool.md)" categories: - C libraries --- **mmmalloc** is a misoptimised memory allocator: my own `malloc`, `free`, `calloc` and `realloc`. It is the new version of *hallocator*, my previous allocator: memory now grows dynamically and `calloc` is implemented. ## Synopsis ``` void *malloc(size_t size); void free(void *_Nullable ptr); void *calloc(size_t nmemb, size_t size); void *realloc(void *_Nullable ptr, size_t size); ``` They follow the usual C11 and POSIX semantics, with one difference: `size` must be greater than 0 (the non-GNU approach). On error they return NULL and set `errno` to `ENOMEM`; nothing makes the program exit. > [!WARNING] > The functions are not thread-safe: locking has to be handled externally. If you notice strange behaviour you think comes from the allocator, open an issue. ## See also - [Source code](https://github.com/hugoocoto/mmmalloc)