rsys

Basic data structures and low-level features
git clone git://git.meso-star.fr/rsys.git
Log | Files | Refs | README | LICENSE

commit 05174e4ecfd79926e27d5e87bf5df814d8b35cbe
parent c90715fbeee729ea113063c9d06426144fd245b0
Author: vaplv <vaplv@free.fr>
Date:   Thu, 15 Oct 2015 09:18:48 +0200

Update the delete function of the free list data structure

Setup the identifier of the deleted item to FID_NULL. One can thus
verify that an item is in-use independently of its current "name" by
indexing this item in the items list and checking that its associated id
is not FID_NULL.

Diffstat:
Msrc/free_list.h | 4++--
Msrc/test_free_list.c | 1+
2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/free_list.h b/src/free_list.h @@ -39,7 +39,7 @@ struct fid { static const struct fid FID_NULL = { UINT32_MAX, UINT32_MAX }; -/* Helper macros that define if a free list identifier is NULL or not */ +/* Helper macros that defines if a free list identifier is NULL or not */ #define IS_FID_NULL(Fid) ((Fid).index == UINT32_MAX) /* Compare 2 free list identifiers */ @@ -182,7 +182,7 @@ FLIST_FUNC__(del)(struct FLIST_TYPE__* list, struct fid id) } /* Add the item to the single linked list of free items */ - item->fitem__.id.name = UINT32_MAX; + item->fitem__.id = FID_NULL; item->fitem__.next = list->head; list->head = item->fitem__.id.index; } diff --git a/src/test_free_list.c b/src/test_free_list.c @@ -117,6 +117,7 @@ main(int argc, char** argv) } else { CHECK(flist_object_hold(&list, id[i]), 0); CHECK(find[i], 0); + CHECK(IS_FID_NULL(object_id_get(list.items + id[i].index)), 1); } }