Wyatt Hepler | f9fb90f | 2020-09-30 18:59:33 -0700 | [diff] [blame] | 1 | .. _module-pw_malloc_freelist: |
Chenghan Zhou | d4f44d2 | 2020-06-18 15:42:06 -0400 | [diff] [blame] | 2 | |
| 3 | ------------------ |
| 4 | pw_malloc_freelist |
| 5 | ------------------ |
| 6 | |
| 7 | ``pw_malloc_freelist`` implements the ``pw_malloc`` facade using a freelist |
| 8 | heap. |
| 9 | |
| 10 | ``pw_malloc_freelist`` initializes a global ``FreeListHeapBuffer`` object to |
| 11 | organize heap usage. Implementation details are in the ``pw_allocator`` module. |
| 12 | |
| 13 | ``pw_malloc_freelist`` provides wrapper functions for ``malloc``, ``free``, |
| 14 | ``realloc`` and ``calloc`` that uses the freelist implementation of heap in |
| 15 | ``pw_allocator``. In the GN build file, ``pw_malloc_freelist`` provides linker |
| 16 | options needed in ``public_configs``, which will be forwarded to the facade. In |
| 17 | the case of freelist, we specify the wrapper functions ``malloc, free, realloc, |
| 18 | calloc, _malloc_r, _free_r, _realloc_r, _calloc_r`` to replace the original libc |
| 19 | functions at linker time. |