summaryrefslogtreecommitdiffstats
path: root/lib.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2014-03-27 19:00:49 -0700
committerKaz Kylheku <kaz@kylheku.com>2014-03-27 19:00:49 -0700
commite44f8e16614283698f648186302ea9d8cadd3066 (patch)
tree66dc0797c7c5d84d798bbe9dfea0685e4b1fac43 /lib.c
parentb6133333a04b6d29c4e6aa45f6e8917cf29ddc99 (diff)
downloadtxr-e44f8e16614283698f648186302ea9d8cadd3066.tar.gz
txr-e44f8e16614283698f648186302ea9d8cadd3066.tar.bz2
txr-e44f8e16614283698f648186302ea9d8cadd3066.zip
More generational GC fixes. One GC fix.
* combi.c (perm_init_common, comb_gen_fun_common, rcomb_gen_fun_common): Use set macro instead of plain assignment. * hash.c (hash_grow, copy_hash, hash_update_1): Use set macro instead of plain assignment. * lib.c (nreverse, lazy_appendv_func, lazy_appendv, vec_push, refset): Use set macro instead of plain assignment. (make_package): Assign all fields of the newly created PKG object before calling a function which can trigger GC. * parser.y (rlset): Use set macro.
Diffstat (limited to 'lib.c')
-rw-r--r--lib.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/lib.c b/lib.c
index a493d875..afcf1689 100644
--- a/lib.c
+++ b/lib.c
@@ -595,7 +595,7 @@ val nreverse(val in)
while (in) {
val temp = cdr(in);
- *cdr_l(in) = rev;
+ set(*cdr_l(in), rev);
rev = in;
in = temp;
}
@@ -782,7 +782,7 @@ static val lazy_appendv_func(val env, val lcons)
{
val *ptail = ltail(&nonempty);
rplaca(env, car(*ptail));
- *ptail = make_lazy_cons(lcons_fun(lcons));
+ set(*ptail, make_lazy_cons(lcons_fun(lcons)));
rplacd(lcons, nonempty);
}
return nil;
@@ -803,8 +803,8 @@ val lazy_appendv(val lists)
{
val *ptail = ltail(&nonempty);
- *ptail = make_lazy_cons(func_f1(cons(car(*ptail), lists),
- lazy_appendv_func));
+ set(*ptail, make_lazy_cons(func_f1(cons(car(*ptail), lists),
+ lazy_appendv_func)));
return nonempty;
}
}
@@ -2746,6 +2746,7 @@ val make_package(val name)
val obj = make_obj();
obj->pk.type = PKG;
obj->pk.name = name;
+ obj->pk.symhash = nil; /* make_hash call below could trigger gc! */
obj->pk.symhash = make_hash(nil, nil, lit("t")); /* don't have t yet! */
push(cons(name, obj), &packages);
@@ -3977,7 +3978,7 @@ val vec_push(val vec, val item)
{
val length = length_vec(vec);
vec_set_length(vec, plus(length, one));
- *vecref_l(vec, length) = item;
+ set(*vecref_l(vec, length), item);
return length;
}
@@ -5041,12 +5042,12 @@ val refset(val seq, val ind, val newval)
case NIL:
case CONS:
case LCONS:
- return *listref_l(seq, ind) = newval;
+ return set(*listref_l(seq, ind), newval);
case LIT:
case STR:
return chr_str_set(seq, ind, newval);
case VEC:
- return *vecref_l(seq, ind) = newval;
+ return set(*vecref_l(seq, ind), newval);
default:
type_mismatch(lit("ref: ~s is not a sequence"), cons, nao);
}