summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@redhat.com>2009-09-18 16:57:55 -0400
committerKristian Høgsberg <krh@redhat.com>2009-09-18 17:05:50 -0400
commitf15ce9f40057495fbe6a21107020358e57aaa430 (patch)
tree91c18cbaca75815cd315765d729109cb89b9dbad
parentecf65fe0411403d57d6d2418782bd741b6d9e034 (diff)
downloadwayland-f15ce9f40057495fbe6a21107020358e57aaa430.tar.gz
wayland-f15ce9f40057495fbe6a21107020358e57aaa430.tar.xz
wayland-f15ce9f40057495fbe6a21107020358e57aaa430.zip
Add a hash remove implementation
-rw-r--r--wayland-util.c13
-rw-r--r--wayland-util.h2
2 files changed, 11 insertions, 4 deletions
diff --git a/wayland-util.c b/wayland-util.c
index 06efd32..cd73542 100644
--- a/wayland-util.c
+++ b/wayland-util.c
@@ -88,11 +88,18 @@ wl_hash_lookup(struct wl_hash *hash, uint32_t id)
}
void
-wl_hash_delete(struct wl_hash *hash, struct wl_object *object)
+wl_hash_remove(struct wl_hash *hash, struct wl_object *object)
{
- /* writeme */
-}
+ int i;
+ for (i = 0; i < hash->count; i++) {
+ if (hash->objects[i]->id == object->id) {
+ hash->objects[i] = hash->objects[hash->count - 1];
+ hash->count--;
+ break;
+ }
+ }
+}
WL_EXPORT void
wl_list_init(struct wl_list *list)
diff --git a/wayland-util.h b/wayland-util.h
index 9da870c..4c3af5d 100644
--- a/wayland-util.h
+++ b/wayland-util.h
@@ -69,7 +69,7 @@ struct wl_hash *wl_hash_create(void);
void wl_hash_destroy(struct wl_hash *hash);
int wl_hash_insert(struct wl_hash *hash, struct wl_object *object);
struct wl_object *wl_hash_lookup(struct wl_hash *hash, uint32_t id);
-void wl_hash_delete(struct wl_hash *hash, struct wl_object *object);
+void wl_hash_remove(struct wl_hash *hash, struct wl_object *object);
struct wl_list {
struct wl_list *prev;