Ignore memory leak of word names
This commit is contained in:
parent
cd77044bf5
commit
bdfc36ea3f
1 changed files with 19 additions and 6 deletions
|
@ -38,6 +38,8 @@ struct hf__result words__char(struct hf__interpreter *const interpreter,
|
|||
|
||||
struct hf__result words__word(struct hf__interpreter *const interpreter,
|
||||
const struct hf__node *const node) {
|
||||
// printf("word = \"%s\"\n", node->value.word.value);
|
||||
|
||||
const struct hf__interpreter__word *const *const word =
|
||||
(const struct hf__interpreter__word *const *const)hf__hashmap__get(
|
||||
&interpreter->words, node->value.word.hash);
|
||||
|
@ -54,7 +56,15 @@ struct hf__result words__word(struct hf__interpreter *const interpreter,
|
|||
&interpreter->call_stack_size, (*word)->body[i]);
|
||||
}
|
||||
|
||||
free(node->value.word.value);
|
||||
/* FIXME: Word name points to copy of pointer of original name,
|
||||
when cleared here all other references loose access to the pointer's value
|
||||
=> SIGSEV!
|
||||
|
||||
For now I am going to ignore the memory leak.
|
||||
Copying the word name may be a better option but is pretty memory
|
||||
inefficient.
|
||||
*/
|
||||
// free(node->value.word.value);
|
||||
|
||||
return HF__OK;
|
||||
}
|
||||
|
@ -353,12 +363,15 @@ hf__interpreter__run(struct hf__interpreter *const interpreter) {
|
|||
|
||||
const struct hf__node *const top =
|
||||
interpreter->call_stack + --interpreter->call_stack_len;
|
||||
SET_8_VALUE_COLOUR(TXT_RED);
|
||||
printf("--- type = %u ---\n", top->type);
|
||||
if (top->type == HF__NODE_TYPE__WORD) {
|
||||
printf("--- word name = \"%s\"\n", top->value.word.value);
|
||||
}
|
||||
SET_8_VALUE_COLOUR(TXT_DEFAULT);
|
||||
|
||||
const hf__interpreter__word_func_t func =
|
||||
HF__INTERPRETER__WORD_FUNCTION[top->type];
|
||||
|
||||
if (func) {
|
||||
return func(interpreter, top);
|
||||
} else {
|
||||
return HF__OK;
|
||||
}
|
||||
return func ? func(interpreter, top) : HF__OK;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue