Add README for the adventurous, allow evdev override from getenv().
[profile/ivi/wayland.git] / hash.c
1 #include <stdlib.h>
2 #include "wayland.h"
3
4 int wl_hash_insert(struct wl_hash *hash, struct wl_object *object)
5 {
6         struct wl_object **objects;
7         uint32_t alloc;
8
9         if (hash->count == hash->alloc) {
10                 if (hash->alloc == 0)
11                         alloc = 16;
12                 else
13                         alloc = hash->alloc * 2;
14                 objects = realloc(hash->objects, alloc * sizeof *objects);
15                 if (objects == NULL)
16                         return -1;
17
18                 hash->objects = objects;
19                 hash->alloc = alloc;
20         }
21
22         hash->objects[hash->count] = object;
23         hash->count++;
24
25         return 0;
26 }
27
28 struct wl_object *
29 wl_hash_lookup(struct wl_hash *hash, uint32_t id)
30 {
31         int i;
32
33         for (i = 0; i < hash->count; i++) {
34                 if (hash->objects[i]->id == id)
35                         return hash->objects[i];
36         }
37
38         return NULL;
39 }
40
41 void
42 wl_hash_delete(struct wl_hash *hash, struct wl_object *object)
43 {
44         /* writeme */
45 }