aboutsummaryrefslogtreecommitdiff
path: root/compile.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-08-04 17:25:54 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-08-04 17:25:54 -0400
commitd7e3d399d6c494ae0b37d8abae25e813aff4316f (patch)
tree1b4fb2bfa54fc8703fda7e04464e71b9daa3c743 /compile.c
parent43501f7bec61d8e8e4430c2226b86579d91a9450 (diff)
Fix up some edge cases with refcounting
Diffstat (limited to 'compile.c')
-rw-r--r--compile.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/compile.c b/compile.c
index 8157a79a..1bad1238 100644
--- a/compile.c
+++ b/compile.c
@@ -2134,7 +2134,7 @@ CORD compile(env_t *env, ast_t *ast)
case TableType: {
if (streq(f->field, "keys")) {
return CORD_all("({ table_t *t = ", compile_to_pointer_depth(env, f->fielded, 1, false), ";\n"
- "t->entries.data_refcount = 3;\n"
+ "ARRAY_INCREF(t->entries);\n"
"t->entries; })");
} else if (streq(f->field, "values")) {
auto table = Match(value_t, TableType);
@@ -2143,7 +2143,7 @@ CORD compile(env_t *env, ast_t *ast)
if (align > 1 && offset % align > 0)
offset += align - (offset % align);
return CORD_all("({ table_t *t = ", compile_to_pointer_depth(env, f->fielded, 1, false), ";\n"
- "t->entries.data_refcount = 3;\n"
+ "ARRAY_INCREF(t->entries.data_refcount);\n"
"(array_t){.data = t->entries.data + ", CORD_asprintf("%zu", offset),
",\n .length=t->entries.length,\n .stride=t->entries.stride,\n .data_refcount=3};})");
} else if (streq(f->field, "fallback")) {