diff options
Diffstat (limited to 'src/std/hash_map.c')
-rw-r--r-- | src/std/hash_map.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/std/hash_map.c b/src/std/hash_map.c index 968a5ea..7ba1daf 100644 --- a/src/std/hash_map.c +++ b/src/std/hash_map.c @@ -43,10 +43,6 @@ void tsl_hash_map_deinit(TslHashMap *self) { /* TODO: Remove if (data) and if (output) */ static int tsl_hash_map_append_bucket(TslHashMapNode **head_node, uint64_t hash, const TslStringView *key, size_t size, const void *data, void **output) { TslHashMapNode *next_node; - /* - TODO: Instead of allocating space for the data, allow the user to pass a pointer in the insert - method and use that directly. - */ uint8_t *node_data = malloc(sizeof(hash) + sizeof(key->size) + key->size + sizeof(size) + size); if(output) *output = node_data; @@ -65,8 +61,13 @@ static int tsl_hash_map_append_bucket(TslHashMapNode **head_node, uint64_t hash, } memcpy(node_data, &hash, sizeof(hash)); + /* TODO: Instead of allocating space for the key, use the key data pointer and size directly. */ memcpy(node_data + sizeof(hash), &key->size, sizeof(key->size)); memcpy(node_data + sizeof(hash) + sizeof(key->size), key->data, key->size); + /* + TODO: Instead of allocating space for the data, allow the user to pass a pointer in the insert + method and use that directly. + */ memcpy(node_data + sizeof(hash) + sizeof(key->size) + key->size, &size, sizeof(size)); if(data) memcpy(node_data + sizeof(hash) + sizeof(key->size) + key->size + sizeof(size), data, size); |