slab: add CLEANUP_KFREE
Signed-off-by: Michael Shaw <m@michaelsshaw.com>
This commit is contained in:
parent
36145eafbc
commit
b838b53942
2 changed files with 8 additions and 0 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue