stuff2
This commit is contained in:
@@ -15,7 +15,7 @@ zn_status_t namespace_new(struct namespace** out) {
|
||||
|
||||
namespace->mutex = (struct mutex){0};
|
||||
namespace->next_handle = 1;
|
||||
HASHMAP_INIT(&namespace->descriptors);
|
||||
hashmap_init(&namespace->descriptors);
|
||||
|
||||
*out = namespace;
|
||||
return ZN_OK;
|
||||
@@ -31,10 +31,10 @@ zn_status_t namespace_add_desc(struct namespace* namespace, struct namespace_des
|
||||
handle = atomic_fetch_add_explicit(&namespace->next_handle, 1, memory_order_acq_rel);
|
||||
if (handle <= ZN_HANDLE_INVALID)
|
||||
continue;
|
||||
} while (HASHMAP_GET(&namespace->descriptors, handle, hashmap_hash_default, hashmap_eq_default) != nullptr);
|
||||
} while (hashmap_get(&namespace->descriptors, handle, hashmap_hash_default, hashmap_eq_default) != nullptr);
|
||||
|
||||
zn_status_t status =
|
||||
HASHMAP_INSERT(&namespace->descriptors, handle, desc, hashmap_hash_default, hashmap_eq_default);
|
||||
hashmap_insert(&namespace->descriptors, handle, desc, hashmap_hash_default, hashmap_eq_default);
|
||||
if (status != ZN_OK)
|
||||
return status;
|
||||
|
||||
@@ -49,10 +49,10 @@ zn_status_t namespace_add_desc_at(struct namespace* namespace, struct namespace_
|
||||
return ZN_ERR_BAD_HANDLE;
|
||||
|
||||
// Fail if a descriptor already exists at this handle.
|
||||
if (HASHMAP_GET(&namespace->descriptors, handle, hashmap_hash_default, hashmap_eq_default) != nullptr)
|
||||
if (hashmap_get(&namespace->descriptors, handle, hashmap_hash_default, hashmap_eq_default) != nullptr)
|
||||
return ZN_ERR_ALREADY_EXISTS;
|
||||
|
||||
return HASHMAP_INSERT(&namespace->descriptors, handle, desc, hashmap_hash_default, hashmap_eq_default);
|
||||
return hashmap_insert(&namespace->descriptors, handle, desc, hashmap_hash_default, hashmap_eq_default);
|
||||
}
|
||||
|
||||
zn_status_t namespace_get(struct namespace* namespace, zn_handle_t handle, struct namespace_desc* out) {
|
||||
@@ -65,7 +65,7 @@ zn_status_t namespace_get(struct namespace* namespace, zn_handle_t handle, struc
|
||||
return ZN_ERR_BAD_HANDLE;
|
||||
|
||||
struct namespace_desc* desc =
|
||||
HASHMAP_GET(&namespace->descriptors, handle, hashmap_hash_default, hashmap_eq_default);
|
||||
hashmap_get(&namespace->descriptors, handle, hashmap_hash_default, hashmap_eq_default);
|
||||
if (!desc)
|
||||
return ZN_ERR_BAD_HANDLE;
|
||||
|
||||
@@ -80,7 +80,7 @@ zn_status_t namespace_del_desc(struct namespace* namespace, zn_handle_t handle)
|
||||
if (handle <= ZN_HANDLE_INVALID)
|
||||
return ZN_ERR_BAD_HANDLE;
|
||||
|
||||
if (!HASHMAP_REMOVE(&namespace->descriptors, handle, hashmap_hash_default, hashmap_eq_default))
|
||||
if (!hashmap_remove(&namespace->descriptors, handle, hashmap_hash_default, hashmap_eq_default))
|
||||
return ZN_ERR_BAD_HANDLE;
|
||||
|
||||
return ZN_OK;
|
||||
|
||||
Reference in New Issue
Block a user