types.h
author Dan Winship <danw@gnome.org>
Fri Feb 08 11:19:36 2008 -0500 (2008-02-08)
changeset 116 4ec6e2a55c34
parent 115 26edeea5c95a
child 117 1c213cbf9da9
permissions -rw-r--r--
Add a list abstraction for package/property lists
     1 #ifndef _RAZOR_TYPES_H_
     2 #define _RAZOR_TYPES_H_
     3 
     4 #include <stdint.h>
     5 
     6 struct array {
     7 	void *data;
     8 	int size, alloc;
     9 };
    10 
    11 void array_init(struct array *array);
    12 void array_release(struct array *array);
    13 void *array_add(struct array *array, int size);
    14 
    15 
    16 void list_init(uint32_t *list);
    17 void list_set(uint32_t *list, struct array *pool, struct array *items);
    18 uint32_t *list_first(uint32_t *list, struct array *pool);
    19 uint32_t *list_next(uint32_t *list);
    20 void list_remap_pool(struct array *pool, uint32_t *map);
    21 void list_remap_if_immediate(uint32_t *list, uint32_t *map);
    22 #define LIST_VALUE(list) (*(list) & RAZOR_ENTRY_MASK)
    23 #define LIST_FLAGS(list) (*(list) & ~RAZOR_ENTRY_MASK)
    24 
    25 struct hashtable {
    26 	struct array buckets;
    27 	struct array *pool;
    28 };
    29 
    30 void hashtable_init(struct hashtable *table, struct array *pool);
    31 void hashtable_release(struct hashtable *table);
    32 uint32_t hashtable_insert(struct hashtable *table, const char *key);
    33 uint32_t hashtable_lookup(struct hashtable *table, const char *key);
    34 uint32_t hashtable_tokenize(struct hashtable *table, const char *string);
    35 
    36 #endif /* _RAZOR_TYPES_H_ */