Mercurial > libjeffpc
changeset 838:8ccd0c9ddaaa
val: move nvl emptying into a helper function
Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author | Josef 'Jeff' Sipek <jeffpc@josefsipek.net> |
---|---|
date | Wed, 12 May 2021 09:56:49 -0400 |
parents | e1afd5b277d6 |
children | 2198701308ed |
files | val_nvl.c |
diffstat | 1 files changed, 11 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/val_nvl.c Wed Mar 03 19:14:43 2021 -0500 +++ b/val_nvl.c Wed May 12 09:56:49 2021 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 Josef 'Jeff' Sipek <jeffpc@josefsipek.net> + * Copyright (c) 2018-2021 Josef 'Jeff' Sipek <jeffpc@josefsipek.net> * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -87,13 +87,16 @@ return val; } -void __val_free_nvl(struct val *val) +static void __val_empty_nvl(struct val *val, bool zero_refs) { struct rb_cookie cookie; struct nvpair *cur; ASSERT(val); - ASSERT3U(refcnt_read(&val->refcnt), ==, 0); + if (zero_refs) + ASSERT3U(refcnt_read(&val->refcnt), ==, 0); + else + ASSERT3U(refcnt_read(&val->refcnt), !=, 0); ASSERT3U(val->type, ==, VT_NVL); memset(&cookie, 0, sizeof(struct rb_cookie)); @@ -102,3 +105,8 @@ rb_destroy(&val->_set_nvl.values); } + +void __val_free_nvl(struct val *val) +{ + __val_empty_nvl(val, true); +}