all repos — hex @ 804a0cc7c8c6263e6c9fb164bb91ce88956e86a4

A tiny, minimalist, slightly-esoteric concatenative programming lannguage.

Merge branch 'hashtable' of git@github.com:h3rald/hex.git
Fabio Cevasco h3rald@h3rald.com
Tue, 31 Dec 2024 22:47:23 +0100
commit

804a0cc7c8c6263e6c9fb164bb91ce88956e86a4

parent

3f49942070c7924101c659f7cf9ee6d8ff2d4444

1 files changed, 6 insertions(+), 4 deletions(-)

jump to
M src/registry.csrc/registry.c

@@ -150,7 +150,7 @@ {

if (strcmp(entry->key, key) == 0) { // Key already exists, update its value - hex_free_item(NULL, entry->value); // Free old value + hex_free_item(ctx, entry->value); // Free old value entry->value = value; return 0; }

@@ -210,12 +210,14 @@ {

if (strcmp(entry->key, key) == 0) { // Key found, copy the value to result - result = hex_copy_item(ctx, entry->value); // Copy the value structure - if (result == NULL) + HEX_ALLOC(item); + item = hex_copy_item(ctx, entry->value); // Copy the value structure + if (item == NULL) { hex_error(ctx, "[get symbol] Failed to copy item for key: %s", key); return 0; } + *result = *item; hex_debug_item(ctx, "DONE", result); return 1; // Success }

@@ -250,7 +252,7 @@ registry->buckets[bucket_index] = entry->next;

} free(entry->key); - hex_free_item(NULL, entry->value); + hex_free_item(ctx, entry->value); free(entry); registry->size--;