fix memory being freed too early

This commit is contained in:
William Bell
2025-08-10 04:39:50 +01:00
parent 49b1c1858a
commit c71375c7a4
12 changed files with 126 additions and 73 deletions

View File

@@ -0,0 +1,28 @@
/*
* SPDX-FileCopyrightText: 2025 William Bell
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#include "term.h"
#include <stddef.h>
#include <stdio.h>
#include "../../call/call.h"
ArgonObject *term_log(size_t argc, ArgonObject **argv, ArErr *err,
RuntimeState *state) {
for (size_t i = 0; i < argc; i++) {
if (i != 0)
printf(" ");
ArgonObject *string_convert_method = get_field_for_class(
get_field(argv[i], "__class__", false, false), "__string__", argv[i]);
if (string_convert_method) {
ArgonObject *string_object =
argon_call(string_convert_method, 0, NULL, err, state);
fwrite(string_object->value.as_str.data, sizeof(char),
string_object->value.as_str.length, stdout);
}
}
printf("\n");
return ARGON_NULL;
}

View File

@@ -0,0 +1,16 @@
/*
* SPDX-FileCopyrightText: 2025 William Bell
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#ifndef runtime_term_H
#define runtime_term_H
#include "../../objects/literals/literals.h"
#include "../../objects/object.h"
#include "../../runtime.h"
ArgonObject *term_log(size_t argc, ArgonObject **argv, ArErr *err,
RuntimeState *state);
#endif // runtime_term_H