diff --git a/include/hexagram/dict.h b/include/hexagram/dict.h index 09912f0..e300d5f 100644 --- a/include/hexagram/dict.h +++ b/include/hexagram/dict.h @@ -37,8 +37,12 @@ int hexagram_dict_each(hexagram_dict *dict, void *hexagram_dict_get(hexagram_dict *dict, void *key, size_t keysz); +void *hexagram_dict_get_s(hexagram_dict *dict, const char *key); + int hexagram_dict_delete(hexagram_dict *dict, void *key, size_t keysz); +int hexagram_dict_delete_s(hexagram_dict *dict, const char *key); + void *hexagram_dict_set_with_hash(hexagram_dict *dict, void *key, void *value, @@ -49,4 +53,6 @@ void *hexagram_dict_set(hexagram_dict *dict, size_t keysz, void *value); +void *hexagram_dict_set_s(hexagram_dict *dict, const char *key, void *value); + #endif /* _HEXAGRAM_DICT_H */ diff --git a/src/dict.c b/src/dict.c index 5a91b12..7f7dfe1 100644 --- a/src/dict.c +++ b/src/dict.c @@ -201,6 +201,10 @@ error_hash: return NULL; } +void *hexagram_dict_get_s(hexagram_dict *dict, const char *key) { + return hexagram_dict_get(dict, (void *)key, strlen(key)); +} + int hexagram_dict_delete(hexagram_dict *dict, void *key, size_t keysz) { hexagram_dict_slot *slot; uint32_t hash; @@ -228,6 +232,10 @@ error_slot_find_readable: return -1; } +int hexagram_dict_delete_s(hexagram_dict *dict, const char *key) { + return hexagram_dict_delete(dict, (void*)key, strlen(key)); +} + void *hexagram_dict_set_with_hash(hexagram_dict *dict, void *key, void *value, @@ -262,3 +270,8 @@ void *hexagram_dict_set(hexagram_dict *dict, error_hash: return NULL; } + +void *hexagram_dict_set_s(hexagram_dict *dict, const char *key, void *value) { + return hexagram_dict_set(dict, (void *)key, strlen(key), value); +} +