From 89ffc2e60a7e7473504721874596e7bebcce896a Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Fri, 12 Aug 2022 17:55:32 -0700 Subject: Chapter 26.5 --- clox/src/table.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'clox/src/table.c') 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]; -- cgit v1.2.3-54-g00ecf