diff options
Diffstat (limited to 'src/jansson/hashtable.h')
-rw-r--r-- | src/jansson/hashtable.h | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/src/jansson/hashtable.h b/src/jansson/hashtable.h index f54c3fe..c112834 100644 --- a/src/jansson/hashtable.h +++ b/src/jansson/hashtable.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2014 Petri Lehtinen <petri@digip.org> + * Copyright (c) 2009-2016 Petri Lehtinen <petri@digip.org> * * This library is free software; you can redistribute it and/or modify * it under the terms of the MIT license. See LICENSE for details. @@ -8,6 +8,9 @@ #ifndef HASHTABLE_H #define HASHTABLE_H +#include <stdlib.h> +#include "jansson.h" + struct hashtable_list { struct hashtable_list *prev; struct hashtable_list *next; @@ -17,10 +20,10 @@ struct hashtable_list { key-value pair. In this case, it just encodes some extra data, too */ struct hashtable_pair { - size_t hash; struct hashtable_list list; + struct hashtable_list ordered_list; + size_t hash; json_t *value; - size_t serial; char key[1]; }; @@ -34,11 +37,12 @@ typedef struct hashtable { struct hashtable_bucket *buckets; size_t order; /* hashtable has pow(2, order) buckets */ struct hashtable_list list; + struct hashtable_list ordered_list; } hashtable_t; #define hashtable_key_to_iter(key_) \ - (&(container_of(key_, struct hashtable_pair, key)->list)) + (&(container_of(key_, struct hashtable_pair, key)->ordered_list)) /** @@ -51,7 +55,7 @@ typedef struct hashtable { * * Returns 0 on success, -1 on error (out of memory). */ -int hashtable_init(hashtable_t *hashtable); +int hashtable_init(hashtable_t *hashtable) JANSSON_ATTRS(warn_unused_result); /** * hashtable_close - Release all resources used by a hashtable object @@ -77,9 +81,7 @@ void hashtable_close(hashtable_t *hashtable); * * Returns 0 on success, -1 on failure (out of memory). */ -int hashtable_set(hashtable_t *hashtable, - const char *key, size_t serial, - json_t *value); +int hashtable_set(hashtable_t *hashtable, const char *key, json_t *value); /** * hashtable_get - Get a value associated with a key @@ -157,13 +159,6 @@ void *hashtable_iter_next(hashtable_t *hashtable, void *iter); void *hashtable_iter_key(void *iter); /** - * hashtable_iter_serial - Retrieve the serial number pointed to by an iterator - * - * @iter: The iterator - */ -size_t hashtable_iter_serial(void *iter); - -/** * hashtable_iter_value - Retrieve the value pointed by an iterator * * @iter: The iterator |