3 * \brief Map implementation
6 * (c) 2008-2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
7 * Ronald Aigner <ra3@os.inf.tu-dresden.de>
8 * economic rights: Technische Universität Dresden (Germany)
9 * This file is part of TUD:OS and distributed under the terms of the
10 * GNU Lesser General Public License 2.1.
11 * Please see the COPYING-LGPL-2.1 file for details.
18 #include <l4/sys/compiler.h>
25 * its basically a single linked list with a
26 * key and a data entry
28 typedef struct slmap_t
30 struct slmap_t* next; /* pointer to next entry */
31 void *key; /* the key of the map entry */
32 unsigned key_size; /* the size of the key entry */
33 void *data; /* the data of the map entry */
41 map_new_entry(void* key, unsigned key_size, void *data);
44 map_new_sentry(char* key, void* data);
47 map_append(slmap_t* list, slmap_t* new_entry);
50 map_remove(slmap_t* list, slmap_t* entry);
53 map_free_entry(slmap_t** entry);
56 map_get_at(slmap_t* list, int n);
59 map_add(slmap_t* list, slmap_t* new_entry);
62 map_insert_after(slmap_t* after, slmap_t* new_entry);
65 map_find(slmap_t* list, void* key, unsigned key_size);
68 map_sfind(slmap_t* list, const char* key);
71 * implementatic of static inline
74 static inline unsigned char
75 map_is_empty(slmap_t* list)
77 return (list) ? 0 : 1;
81 map_free(slmap_t **list)
84 *list = map_remove(*list, *list);
88 map_elements(slmap_t* list)
91 for (n=0; list; list=list->next)