[set] Allow a set pool to be cleaned up

In the end, I couldn't use it (due to needing to hold onto the sets),
but it balances the init.
This commit is contained in:
Bill Currie 2024-09-19 12:22:46 +09:00
parent e477148a9b
commit 2768606f1d
2 changed files with 9 additions and 2 deletions

View file

@ -125,6 +125,7 @@ typedef struct set_pool_s {
} set_pool_t;
void set_pool_init (set_pool_t *set_pool);
void set_pool_clear (set_pool_t *set_pool);
/** Delete a set iterator that is no longer needed.

View file

@ -86,6 +86,13 @@ set_pool_init (set_pool_t *set_pool)
};
}
void
set_pool_clear (set_pool_t *set_pool)
{
ALLOC_FREE_BLOCKS (set_pool->set);
ALLOC_FREE_BLOCKS (set_pool->set_iter);
}
inline set_t *
set_new_r (set_pool_t *set_pool)
{
@ -835,8 +842,7 @@ set_as_string (const set_t *set)
static void
set_shutdown (void *data)
{
ALLOC_FREE_BLOCKS (static_set_pool.set);
ALLOC_FREE_BLOCKS (static_set_pool.set_iter);
set_pool_clear (&static_set_pool);
}
static void __attribute__((constructor))