diff options
author | 3gg <3gg@shellblade.net> | 2023-01-23 16:54:36 -0800 |
---|---|---|
committer | 3gg <3gg@shellblade.net> | 2023-01-23 16:54:36 -0800 |
commit | 007aa328fcf973b47fcfd8225ab9077cb3c45145 (patch) | |
tree | 9f1bc4db5d4edd5cd0bee634592b04408ac75b13 /listpool/src | |
parent | d22337cb86b196ce6a953219fa4bd46a31d144dd (diff) |
Format.
Diffstat (limited to 'listpool/src')
-rw-r--r-- | listpool/src/listpool.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/listpool/src/listpool.c b/listpool/src/listpool.c index 9c86a3b..8e49f32 100644 --- a/listpool/src/listpool.c +++ b/listpool/src/listpool.c | |||
@@ -2,15 +2,16 @@ | |||
2 | 2 | ||
3 | #include <string.h> | 3 | #include <string.h> |
4 | 4 | ||
5 | void listpool_make_(listpool* pool, list* nodes, void* blocks, | 5 | void listpool_make_( |
6 | size_t num_blocks, size_t block_size_bytes) { | 6 | listpool* pool, list* nodes, void* blocks, size_t num_blocks, |
7 | size_t block_size_bytes) { | ||
7 | assert(pool); | 8 | assert(pool); |
8 | pool->block_size_bytes = block_size_bytes; | 9 | pool->block_size_bytes = block_size_bytes; |
9 | pool->num_blocks = num_blocks; | 10 | pool->num_blocks = num_blocks; |
10 | pool->free = &nodes[0]; | 11 | pool->free = &nodes[0]; |
11 | pool->used = 0; | 12 | pool->used = 0; |
12 | pool->nodes = nodes; | 13 | pool->nodes = nodes; |
13 | pool->blocks = blocks; | 14 | pool->blocks = blocks; |
14 | list_make(nodes, num_blocks); | 15 | list_make(nodes, num_blocks); |
15 | memset(blocks, 0, num_blocks * block_size_bytes); | 16 | memset(blocks, 0, num_blocks * block_size_bytes); |
16 | } | 17 | } |
@@ -69,9 +70,9 @@ void listpool_free_(listpool* pool, void** block_ptr) { | |||
69 | if (!pool->free) { | 70 | if (!pool->free) { |
70 | pool->free = item; | 71 | pool->free = item; |
71 | } else { | 72 | } else { |
72 | item->next = pool->free; | 73 | item->next = pool->free; |
73 | pool->free->prev = item; | 74 | pool->free->prev = item; |
74 | pool->free = item; | 75 | pool->free = item; |
75 | } | 76 | } |
76 | 77 | ||
77 | *block_ptr = 0; | 78 | *block_ptr = 0; |