Reformat & cleanup

This commit is contained in:
Nils O. Selåsdal
2026-04-19 04:22:23 +02:00
parent 64a5b20941
commit aba9cba602
2 changed files with 62 additions and 71 deletions
+10 -14
View File
@@ -9,8 +9,8 @@ extern "C" {
typedef union UCPoolBlock UCPoolBlock;
union UCPoolBlock {
UCPoolBlock *next; // next free block (when not allocated)
unsigned char data[]; // data when allocated
UCPoolBlock *next; // next free block (when not allocated)
unsigned char data[0]; // data when allocated
};
/** @file
* Static pool allocator.
@@ -25,15 +25,15 @@ union UCPoolBlock {
* @endcode
* as the backing buffer.
*
*/
*/
typedef struct UCPool UCPool;
struct UCPool {
UCPoolBlock *free_list; // free list
size_t block_size; // aligned size of each block
size_t capacity; // number of blocks
size_t align; // alignment
UCPoolBlock *start; // start of user buffer
UCPoolBlock *end; // one past end of user buffer
UCPoolBlock *free_list; // free list
size_t block_size; // aligned size of each block
size_t capacity; // number of blocks
size_t align; // alignment
UCPoolBlock *start; // start of user buffer
UCPoolBlock *end; // one past end of user buffer
};
/** Initialize the pool.
@@ -45,11 +45,7 @@ struct UCPool {
* @param block_size size of each allocation.
* @param alignment alignment of each block (must be power of 2)
*/
void uc_pool_init(UCPool *pool,
void *buffer,
size_t buffer_size,
size_t block_size,
size_t alignment);
void uc_pool_init(UCPool *pool, void *buffer, size_t buffer_size, size_t block_size, size_t alignment);
// Allocate a block from the pool. Returns NULL if no more space
[[gnu::assume_aligned(_Alignof(UCPoolBlock))]]