aboutsummaryrefslogtreecommitdiffstats
path: root/clox/src/table.c
diff options
context:
space:
mode:
authorGravatar Tom Willemse2022-08-12 17:55:32 -0700
committerGravatar Tom Willemse2022-08-12 17:55:32 -0700
commit89ffc2e60a7e7473504721874596e7bebcce896a (patch)
treebabdcdf20db8ce57f32bbf332cf169f34bb46bfb /clox/src/table.c
parent14b3866ac09c80b8f34d79227d743eabb2da0f2a (diff)
downloadcrafting-interpreters-89ffc2e60a7e7473504721874596e7bebcce896a.tar.gz
crafting-interpreters-89ffc2e60a7e7473504721874596e7bebcce896a.zip
Chapter 26.5
Diffstat (limited to 'clox/src/table.c')
-rw-r--r--clox/src/table.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/clox/src/table.c b/clox/src/table.c
index ae34ab0..134f455 100644
--- a/clox/src/table.c
+++ b/clox/src/table.c
@@ -141,6 +141,15 @@ ObjString *tableFindString(Table *table, const char *chars, int length,
}
}
+void tableRemoveWhite(Table *table) {
+ for (int i = 0; i < table->capacity; i++) {
+ Entry *entry = &table->entries[i];
+ if (entry->key != NULL && !entry->key->obj.isMarked) {
+ tableDelete(table, entry->key);
+ }
+ }
+}
+
void markTable(Table *table) {
for (int i = 0; i < table->capacity; i++) {
Entry *entry = &table->entries[i];