diff options
author | Dag-Erling Smørgrav <des@FreeBSD.org> | 2018-09-10 16:30:18 +0000 |
---|---|---|
committer | Dag-Erling Smørgrav <des@FreeBSD.org> | 2018-09-10 16:30:18 +0000 |
commit | 7b6fdf425a9ef38fe9e16779b3af25863104d9c0 (patch) | |
tree | 1ac9dd11604f49ca6a2feae373ff4dc7e6fb0002 /util/alloc.c | |
parent | 4289761a7b61df4b64c11ada446a187df61e6a1e (diff) |
Diffstat (limited to 'util/alloc.c')
-rw-r--r-- | util/alloc.c | 42 |
1 files changed, 32 insertions, 10 deletions
diff --git a/util/alloc.c b/util/alloc.c index 2c6e1a23f6c02..908b1f42361f2 100644 --- a/util/alloc.c +++ b/util/alloc.c @@ -126,10 +126,40 @@ alloc_init(struct alloc_cache* alloc, struct alloc_cache* super, } } +/** free the special list */ +static void +alloc_clear_special_list(struct alloc_cache* alloc) +{ + alloc_special_type* p, *np; + /* free */ + p = alloc->quar; + while(p) { + np = alloc_special_next(p); + /* deinit special type */ + lock_rw_destroy(&p->entry.lock); + free(p); + p = np; + } +} + +void +alloc_clear_special(struct alloc_cache* alloc) +{ + if(!alloc->super) { + lock_quick_lock(&alloc->lock); + } + alloc_clear_special_list(alloc); + alloc->quar = 0; + alloc->num_quar = 0; + if(!alloc->super) { + lock_quick_unlock(&alloc->lock); + } +} + void alloc_clear(struct alloc_cache* alloc) { - alloc_special_type* p, *np; + alloc_special_type* p; struct regional* r, *nr; if(!alloc) return; @@ -147,15 +177,7 @@ alloc_clear(struct alloc_cache* alloc) alloc->super->num_quar += alloc->num_quar; lock_quick_unlock(&alloc->super->lock); } else { - /* free */ - p = alloc->quar; - while(p) { - np = alloc_special_next(p); - /* deinit special type */ - lock_rw_destroy(&p->entry.lock); - free(p); - p = np; - } + alloc_clear_special_list(alloc); } alloc->quar = 0; alloc->num_quar = 0; |