hashtable.h (jansson-2.13.1.tar.bz2) | : | hashtable.h (jansson-2.14.tar.bz2) | ||
---|---|---|---|---|
skipping to change at line 27 | skipping to change at line 27 | |||
}; | }; | |||
/* "pair" may be a bit confusing a name, but think of it as a | /* "pair" may be a bit confusing a name, but think of it as a | |||
key-value pair. In this case, it just encodes some extra data, | key-value pair. In this case, it just encodes some extra data, | |||
too */ | too */ | |||
struct hashtable_pair { | struct hashtable_pair { | |||
struct hashtable_list list; | struct hashtable_list list; | |||
struct hashtable_list ordered_list; | struct hashtable_list ordered_list; | |||
size_t hash; | size_t hash; | |||
json_t *value; | json_t *value; | |||
size_t key_len; | ||||
char key[1]; | char key[1]; | |||
}; | }; | |||
struct hashtable_bucket { | struct hashtable_bucket { | |||
struct hashtable_list *first; | struct hashtable_list *first; | |||
struct hashtable_list *last; | struct hashtable_list *last; | |||
}; | }; | |||
typedef struct hashtable { | typedef struct hashtable { | |||
size_t size; | size_t size; | |||
skipping to change at line 72 | skipping to change at line 73 | |||
* | * | |||
* Destroys a statically allocated hashtable object. | * Destroys a statically allocated hashtable object. | |||
*/ | */ | |||
void hashtable_close(hashtable_t *hashtable); | void hashtable_close(hashtable_t *hashtable); | |||
/** | /** | |||
* hashtable_set - Add/modify value in hashtable | * hashtable_set - Add/modify value in hashtable | |||
* | * | |||
* @hashtable: The hashtable object | * @hashtable: The hashtable object | |||
* @key: The key | * @key: The key | |||
* @key: The length of key | ||||
* @serial: For addition order of keys | * @serial: For addition order of keys | |||
* @value: The value | * @value: The value | |||
* | * | |||
* If a value with the given key already exists, its value is replaced | * If a value with the given key already exists, its value is replaced | |||
* with the new value. Value is "stealed" in the sense that hashtable | * with the new value. Value is "stealed" in the sense that hashtable | |||
* doesn't increment its refcount but decreases the refcount when the | * doesn't increment its refcount but decreases the refcount when the | |||
* value is no longer needed. | * value is no longer needed. | |||
* | * | |||
* Returns 0 on success, -1 on failure (out of memory). | * Returns 0 on success, -1 on failure (out of memory). | |||
*/ | */ | |||
int hashtable_set(hashtable_t *hashtable, const char *key, json_t *value); | int hashtable_set(hashtable_t *hashtable, const char *key, size_t key_len, json_ t *value); | |||
/** | /** | |||
* hashtable_get - Get a value associated with a key | * hashtable_get - Get a value associated with a key | |||
* | * | |||
* @hashtable: The hashtable object | * @hashtable: The hashtable object | |||
* @key: The key | * @key: The key | |||
* @key: The length of key | ||||
* | * | |||
* Returns value if it is found, or NULL otherwise. | * Returns value if it is found, or NULL otherwise. | |||
*/ | */ | |||
void *hashtable_get(hashtable_t *hashtable, const char *key); | void *hashtable_get(hashtable_t *hashtable, const char *key, size_t key_len); | |||
/** | /** | |||
* hashtable_del - Remove a value from the hashtable | * hashtable_del - Remove a value from the hashtable | |||
* | * | |||
* @hashtable: The hashtable object | * @hashtable: The hashtable object | |||
* @key: The key | * @key: The key | |||
* @key: The length of key | ||||
* | * | |||
* Returns 0 on success, or -1 if the key was not found. | * Returns 0 on success, or -1 if the key was not found. | |||
*/ | */ | |||
int hashtable_del(hashtable_t *hashtable, const char *key); | int hashtable_del(hashtable_t *hashtable, const char *key, size_t key_len); | |||
/** | /** | |||
* hashtable_clear - Clear hashtable | * hashtable_clear - Clear hashtable | |||
* | * | |||
* @hashtable: The hashtable object | * @hashtable: The hashtable object | |||
* | * | |||
* Removes all items from the hashtable. | * Removes all items from the hashtable. | |||
*/ | */ | |||
void hashtable_clear(hashtable_t *hashtable); | void hashtable_clear(hashtable_t *hashtable); | |||
skipping to change at line 135 | skipping to change at line 139 | |||
* hashtable_iter_next() may be called on an iterator, and after that | * hashtable_iter_next() may be called on an iterator, and after that | |||
* the key/value pair pointed by the old iterator may be deleted. | * the key/value pair pointed by the old iterator may be deleted. | |||
*/ | */ | |||
void *hashtable_iter(hashtable_t *hashtable); | void *hashtable_iter(hashtable_t *hashtable); | |||
/** | /** | |||
* hashtable_iter_at - Return an iterator at a specific key | * hashtable_iter_at - Return an iterator at a specific key | |||
* | * | |||
* @hashtable: The hashtable object | * @hashtable: The hashtable object | |||
* @key: The key that the iterator should point to | * @key: The key that the iterator should point to | |||
* @key: The length of key | ||||
* | * | |||
* Like hashtable_iter() but returns an iterator pointing to a | * Like hashtable_iter() but returns an iterator pointing to a | |||
* specific key. | * specific key. | |||
*/ | */ | |||
void *hashtable_iter_at(hashtable_t *hashtable, const char *key); | void *hashtable_iter_at(hashtable_t *hashtable, const char *key, size_t key_len) ; | |||
/** | /** | |||
* hashtable_iter_next - Advance an iterator | * hashtable_iter_next - Advance an iterator | |||
* | * | |||
* @hashtable: The hashtable object | * @hashtable: The hashtable object | |||
* @iter: The iterator | * @iter: The iterator | |||
* | * | |||
* Returns a new iterator pointing to the next element in the | * Returns a new iterator pointing to the next element in the | |||
* hashtable or NULL if the whole hastable has been iterated over. | * hashtable or NULL if the whole hastable has been iterated over. | |||
*/ | */ | |||
void *hashtable_iter_next(hashtable_t *hashtable, void *iter); | void *hashtable_iter_next(hashtable_t *hashtable, void *iter); | |||
/** | /** | |||
* hashtable_iter_key - Retrieve the key pointed by an iterator | * hashtable_iter_key - Retrieve the key pointed by an iterator | |||
* | * | |||
* @iter: The iterator | * @iter: The iterator | |||
*/ | */ | |||
void *hashtable_iter_key(void *iter); | void *hashtable_iter_key(void *iter); | |||
/** | /** | |||
* hashtable_iter_key_len - Retrieve the key length pointed by an iterator | ||||
* | ||||
* @iter: The iterator | ||||
*/ | ||||
size_t hashtable_iter_key_len(void *iter); | ||||
/** | ||||
* hashtable_iter_value - Retrieve the value pointed by an iterator | * hashtable_iter_value - Retrieve the value pointed by an iterator | |||
* | * | |||
* @iter: The iterator | * @iter: The iterator | |||
*/ | */ | |||
void *hashtable_iter_value(void *iter); | void *hashtable_iter_value(void *iter); | |||
/** | /** | |||
* hashtable_iter_set - Set the value pointed by an iterator | * hashtable_iter_set - Set the value pointed by an iterator | |||
* | * | |||
* @iter: The iterator | * @iter: The iterator | |||
End of changes. 10 change blocks. | ||||
4 lines changed or deleted | 16 lines changed or added |