|
|
|
|
|
by 8dcc
525 days ago
|
|
> I would do exactly the dual: the chunk's size should be defined at pool creation, so that you can create multiple pools, each dedicated to one specific kind of object. This is supported in my 'libpool' project. I thought I mentioned it in the article, but now I am not so sure. https://github.com/8dcc/libpool/blob/main/src/libpool.h#L51 > Similarly, I don't like exposing pool_expand(): too much burden on the user. Expansion should be automatically triggered by pool_alloc() whenever the current pool is exhausted. I feel like this shouldn't be too hard to do, but I actually did write a function for this in another project I am working on. https://github.com/8dcc/sl/blob/9ddd84d75ffc3b0ba1373bc13bc6... > This would also allow a much simpler pool_new() that just initializes its pointers to NULL, leaving it to the first invocation of pool_alloc() to actually do the first allocation. I didn't think of this, but I rather keep the two functions separate, specially for readability in the article. |
|