Use reference counting for identifiers

This commit is contained in:
2026-06-17 10:11:15 +10:00
parent 6d35acbe60
commit b4e481ed9c
16 changed files with 112 additions and 156 deletions

View File

@@ -1,7 +1,6 @@
#include "../../include/ground.h"
#include <string.h>
void _GroundFunctionAppendArg(GroundFunction* function, const char* argName) {
void _GroundFunctionAppendArg(GroundFunction* function, GroundIdentifier* argName) {
if (function->isNativeFunction) {
Ground.Log.Error("Cannot add arg to native function in Ground.Function.appendArg()");
Ground.Flags.error = true;
@@ -19,14 +18,6 @@ void _GroundFunctionAppendArg(GroundFunction* function, const char* argName) {
function->args.capacity *= 2;
}
size_t len = strlen(argName);
function->args.at[function->args.count].as.id = malloc(sizeof(char) * (len + 1));
if (function->args.at[function->args.count].as.id == NULL) {
Ground.Log.Error("malloc failed in Ground.Function.appendArg()");
Ground.Flags.error = true;
return;
}
strcpy(function->args.at[function->args.count].as.id, argName);
function->args.at[function->args.count].as.id = Ground.Copy.Identifier(argName);
function->args.count++;
}