12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- #include <assert.h>
- #include "private.h"
- void
- lub_blockpool_init(lub_blockpool_t * this,
- void *memory, size_t blocksize, unsigned blockcount)
- {
- unsigned i;
- char *ptr = memory;
-
- assert((blocksize & (sizeof(void *) - 1)) == 0);
-
- this->m_head = this->m_tail = NULL;
-
- for (i = 0; i < blockcount; ++i) {
- lub_blockpool_free(this, ptr);
- ptr += blocksize;
- }
-
- this->m_block_size = blocksize;
- this->m_num_blocks = blockcount;
- this->m_alloc_blocks = 0;
- this->m_alloc_total_blocks = 0;
- this->m_alloc_hightide_blocks = 0;
- this->m_alloc_failures = 0;
- }
|