diff options
Diffstat (limited to 'listpool/src/listpool.c')
-rw-r--r-- | listpool/src/listpool.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/listpool/src/listpool.c b/listpool/src/listpool.c index 8e49f32..758062c 100644 --- a/listpool/src/listpool.c +++ b/listpool/src/listpool.c | |||
@@ -77,3 +77,16 @@ void listpool_free_(listpool* pool, void** block_ptr) { | |||
77 | 77 | ||
78 | *block_ptr = 0; | 78 | *block_ptr = 0; |
79 | } | 79 | } |
80 | |||
81 | void* listpool_get_block_(const listpool* pool, size_t block_index) { | ||
82 | assert(pool); | ||
83 | assert(block_index < pool->num_blocks); | ||
84 | return pool->blocks + block_index * pool->block_size_bytes; | ||
85 | } | ||
86 | |||
87 | size_t listpool_get_block_index_(const listpool* pool, const void* block) { | ||
88 | assert(pool); | ||
89 | const size_t block_byte_index = (const uint8_t*)block - pool->blocks; | ||
90 | assert(block_byte_index % pool->block_size_bytes == 0); | ||
91 | return block_byte_index / pool->block_size_bytes; | ||
92 | } | ||