diff options
author | 3gg <3gg@shellblade.net> | 2023-01-23 18:32:49 -0800 |
---|---|---|
committer | 3gg <3gg@shellblade.net> | 2023-01-23 18:32:49 -0800 |
commit | 470a25323ca89ffa3b0b697aeddcf184d12a1382 (patch) | |
tree | c5076734e0154d5a3189105f61dc5f9a526a8e07 /listpool/src | |
parent | f5b77325c44649bb92fa379b7df77c275f3925dc (diff) |
Update listpool's interface to be on par with mempool's.
Diffstat (limited to 'listpool/src')
-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 | } | ||