/*! * This function heap-allocates a new Environment struct, initializes it to be * empty, and then records the struct's pointer in the allocated_environments * vector. */ Environment * alloc_environment(void) { Environment *env = malloc(sizeof(Environment)); memset(env, 0, sizeof(Environment)); pv_add_elem(&allocated_environments, env); return env; }
/*! * This function heap-allocates a new Value struct, initializes it to be empty, * and then records the struct's pointer in the allocated_values vector. */ Value * alloc_value(void) { Value *v = malloc(sizeof(Value)); memset(v, 0, sizeof(Value)); pv_add_elem(&allocated_values, v); return v; }
/*! * This function heap-allocates a new Lambda struct, initializes it to be empty, * and then records the struct's pointer in the allocated_lambdas vector. */ Lambda * alloc_lambda(void) { Lambda *f = malloc(sizeof(Lambda)); memset(f, 0, sizeof(Lambda)); pv_add_elem(&allocated_lambdas, f); return f; }
void evalctx_register(Value **v) { EvaluationContext *ctx; assert(v != NULL); ctx = get_current_evalctx(); pv_add_elem(&ctx->local_vals, v); *v = NULL; }