<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/95589>95589</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Add a per-target way for specifying the buffer size for the freelist heap allocator
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            libc
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          PiJoules
      </td>
    </tr>
</table>

<pre>
    Right now, the freelist allocator just assumes [1GB](https://github.com/llvm/llvm-project/blob/cc7a18c18011d1e0c70187ceb60e3e69bf7cd0ee/libc/src/stdlib/freelist_malloc.cpp#L25) of storage for a buffer size. We should come up with a smarter way of selecting this. For tests on linux, this is valid enough to assert we can allocate enough for tests, but for embedded devices where this will likely be used initially. We have a hole where uses can specify the `LIBC_FREELIST_MALLOC_SIZE` macro at build time, but for default configs, it would be nice to have something similar to what scudo or [sanitizer allocators](https://github.com/llvm/llvm-project/blob/cc7a18c18011d1e0c70187ceb60e3e69bf7cd0ee/compiler-rt/lib/asan/asan_allocator.h#L186) have.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8VE1v6zYQ_DXUZRFBoi1ZOuiQpFGRwkWL9woU6MWgyJXIlBIFLmnX-fUF5bjJtZd3EaGv4czsDAWRmRbEjlVPrPopEzFo57vfzS8uWqRscOrafTOTDrC4C-PPEDTC6BGtoQDCWidFcB7eYrolijMSsOqp_DnhMd7oEFZiu0fGe8b7yQQdh1y6mfHe2vN9eVi9e0MZGO8H6wbGeykPomxk2RRlqUos5KEom4PEoS5wh3U7jAepCsQEYAbJeE9-uwZlTQK4kzzNG8tcrivjuyOvGG_BjUDBeTEhjM6DgCGOI3og8445_IlA2kWrQLoZIa5wMUGDAJqFD-jhIq4bBFqUwSwTBG0oh955CEiBwC1gzRL_uTlmCAzBWVijABcXJw3BJbfQB7ggSLHcrcT7B-MdK0EMMWwPcB5QKVSg8GwkElw0erztcDHWgjV_o73CgBAJFZjFBCOsvW6atDgjCNDO4sePkZC23WlFacbrNl1WF8fXp-dT_-3l5fj6_Y_Tr4_H42_Pp--vf72wuoBZSO9ABBiisQqCmfErR4WjiDaAdMtopo2-CXDZ7BwQFiMxqd_IkJsx6GQgmdlY4dObixYBSEblwPmUJRJJxjv6z7zRDwuXdPNqLPoHH25RY7wXJJaP5fQfpVyneJVNnfKV1OWZ6naq3bUiw648lM2u5U3VZrqrVNWOVTW0ZdHKWtWNKJqDqoXYN7t2LNrMdLzg-6Iu92XLi6rNa2ylqsdWjIdhrPYV2xc4C2PzpC93fsoMUcSuraqmzawY0NLWac5v7eCp3b7b7BjiRGxfpHLQJ0AwwWL3qBQIWNE_BOEnDFvU01g_EnILO37tyy2qX48FjWL9nFUWve3-96Q2PcR4f5N07vi_AQAA__9utJEL">