summaryrefslogtreecommitdiffstats
path: root/hash.h
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-07-20 23:26:38 -0700
committerKaz Kylheku <kaz@kylheku.com>2021-07-20 23:26:38 -0700
commit5613a3b0d42a89d061df18cd9ae4e1008696572c (patch)
treecf810df036b366a9f3fab00117db639e2b6c4378 /hash.h
parenta6f0c72306da0c628be9e180288f79fbf29bfa57 (diff)
downloadtxr-5613a3b0d42a89d061df18cd9ae4e1008696572c.tar.gz
txr-5613a3b0d42a89d061df18cd9ae4e1008696572c.tar.bz2
txr-5613a3b0d42a89d061df18cd9ae4e1008696572c.zip
parse/eval: use weak-both hash tables.
This addresses the problem that a4c376979d15323ad729e92e41ba43768e8dc163 tried to fix. * eval.c (eval_init): Make all the top-level binding tables, top_fb, top_vb, top_mb, top_smb, special and builtin, weak-both tables: keys and values are weak. This way, the entries disappear if both key and value are unreachable, even if they refer to each other. (eval_compat_fixup): In 266 or earlier compat mode, weak-both tables don't have the right semantics, so we tweak the tables to weak-key tables. * parser.c (parse_init): Same treatment for stream_parser_hash. We want an entry to disappear from the hash if neither the parser nor the stream are reachable. (parse_compat_fixup): New function. * parser.h (parse_compat_function): Declared. * hash.c, hash.h (tweak_hash): New function. * lib.c (compat_fixup): Call parse_compat_fixup.
Diffstat (limited to 'hash.h')
-rw-r--r--hash.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/hash.h b/hash.h
index 8792b609..3b773a6b 100644
--- a/hash.h
+++ b/hash.h
@@ -39,6 +39,7 @@ extern struct cobj_class *hash_cls;
ucnum equal_hash(val obj, int *count, ucnum);
val make_seeded_hash(val weak_keys, val weak_vals, val equal_based, val seed);
+val tweak_hash(val hash, val weak_keys, val weak_vals);
val make_hash(val weak_keys, val weak_vals, val equal_based);
val make_eq_hash(val weak_keys, val weak_vals);
val make_similar_hash(val existing);