From 821706e0e444b9a68e321ec1311ea0b70a56b8e7 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Mon, 15 Jun 2020 16:36:52 -0500 Subject: [PATCH] u/hashmap: Add "empty" function. Used for cleanup assertions to start with: i.e. at some known point, the hash map should be empty. --- src/xrt/auxiliary/util/u_hashmap.cpp | 6 ++++++ src/xrt/auxiliary/util/u_hashmap.h | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/xrt/auxiliary/util/u_hashmap.cpp b/src/xrt/auxiliary/util/u_hashmap.cpp index 325f1cd65..7d65135ca 100644 --- a/src/xrt/auxiliary/util/u_hashmap.cpp +++ b/src/xrt/auxiliary/util/u_hashmap.cpp @@ -73,6 +73,12 @@ u_hashmap_int_erase(struct u_hashmap_int *hmi, uint64_t key) return 0; } +bool +u_hashmap_int_empty(const struct u_hashmap_int *hmi) +{ + return hmi->map.empty(); +} + extern "C" void u_hashmap_int_clear_and_call_for_each(struct u_hashmap_int *hmi, u_hashmap_int_callback cb, diff --git a/src/xrt/auxiliary/util/u_hashmap.h b/src/xrt/auxiliary/util/u_hashmap.h index a123e1b26..f9afcf0b5 100644 --- a/src/xrt/auxiliary/util/u_hashmap.h +++ b/src/xrt/auxiliary/util/u_hashmap.h @@ -41,6 +41,12 @@ u_hashmap_int_insert(struct u_hashmap_int *hmi, uint64_t key, void *value); int u_hashmap_int_erase(struct u_hashmap_int *hmi, uint64_t key); +/*! + * Is the hash map empty? + */ +bool +u_hashmap_int_empty(const struct u_hashmap_int *hmi); + /*! * First clear the hashmap and then call the given callback with each item that * was in the hashmap.