all repos — hex @ 942d57f9c575c844f5214db8098c7ec609ad7dda

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

Fixing errors.
h3rald h3rald@h3rald.com
Fri, 27 Dec 2024 15:49:57 +0100
commit

942d57f9c575c844f5214db8098c7ec609ad7dda

parent

52899c183a5d3ae44129251be98ac64ccaae3d8d

3 files changed, 17 insertions(+), 3 deletions(-)

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

@@ -8,9 +8,16 @@ ////////////////////////////////////////

void hex_set_doc(hex_doc_dictionary_t *dict, const char *name, const char *input, const char *output, const char *description) { - hex_doc_entry_t doc = {.name = name, .description = description, .input = input, .output = output}; - // No overflow check as the dictionary is fixed size - *(dict->entries[dict->size]) = doc; + hex_doc_entry_t *doc = malloc(sizeof(hex_doc_entry_t)); + if (doc == NULL) + { + return; + } + doc->name = name; + doc->description = description; + doc->input = input; + doc->output = output; + dict->entries[dict->size] = doc; dict->size++; }
M src/parser.csrc/parser.c

@@ -33,6 +33,7 @@ }

hex_token_t *token = (hex_token_t *)malloc(sizeof(hex_token_t)); token->value = NULL; + token->position = (hex_file_position_t *)malloc(sizeof(hex_file_position_t)); token->position->line = position->line; token->position->column = position->column;
M src/registry.csrc/registry.c

@@ -67,6 +67,12 @@ hex_free_token(value->token);

return 1; } + ctx->registry->entries[ctx->registry->size] = malloc(sizeof(hex_registry_entry_t)); + if (ctx->registry->entries[ctx->registry->size] == NULL) + { + hex_error(ctx, "Error: Memory allocation failed for registry entry"); + return 1; + } ctx->registry->entries[ctx->registry->size]->key = strdup(key); ctx->registry->entries[ctx->registry->size]->value = value; ctx->registry->size++;