Stop pointer parameters leaking value-pool slots #43

Merged
andrew merged 4 commits from 36 into main 2026-08-06 12:38:29 -04:00
Showing only changes of commit 530898533d - Show all commits

View File

@@ -306,6 +306,21 @@ akerr_ErrorContext *akbasic_environment_get(akbasic_Environment *obj, const char
SUCCEED_RETURN(errctx); SUCCEED_RETURN(errctx);
} }
/**
* @brief Create a variable slot in the given scope, optionally allocating its storage.
*
* Shared by akbasic_environment_create() and akbasic_environment_create_empty(),
* which differ only in whether the new variable's value storage is initialized
* immediately or left for the caller to set up.
*
* @param obj Scope the variable is created in; only this scope is searched or
* written to, unlike akbasic_environment_get()'s walk up the parent chain.
* @param varname Name of the variable to create.
* @param dest Set to the created (or already-existing) variable.
* @param initialize When true, the variable's value storage is allocated from
* the runtime's value pool; when false, the caller must initialize it
* before the variable is evaluated.
*/
static akerr_ErrorContext *environment_create_named(akbasic_Environment *obj, const char *varname, static akerr_ErrorContext *environment_create_named(akbasic_Environment *obj, const char *varname,
akbasic_Variable **dest, bool initialize) akbasic_Variable **dest, bool initialize)
{ {