slab: add CLEANUP_KFREE

Signed-off-by: Michael Shaw <m@michaelsshaw.com>
This commit is contained in:
Michael Shaw 2026-07-21 08:10:22 -04:00
commit b838b53942
2 changed files with 8 additions and 0 deletions

View file

@ -8,6 +8,8 @@
#define ALLOC_KERN 0x1
#define ALLOC_USER 0x2
#define CLEANUP_KFREE __attribute__((cleanup(_cleanup_kfree)))
typedef struct _mem_cache_t {
char *name;
size_t item_size;

View file

@ -105,3 +105,9 @@ void slab_free(mem_cache_t *cache, void *ptr)
spinlock_release(&cache->lock);
}
void _cleanup_kfree(void **ptr)
{
if (ptr && *ptr)
kfree(ptr);
}