diff options
author | Tom Willemse | 2022-08-12 17:55:32 -0700 |
---|---|---|
committer | Tom Willemse | 2022-08-12 17:55:32 -0700 |
commit | 89ffc2e60a7e7473504721874596e7bebcce896a (patch) | |
tree | babdcdf20db8ce57f32bbf332cf169f34bb46bfb /clox/src/table.c | |
parent | 14b3866ac09c80b8f34d79227d743eabb2da0f2a (diff) | |
download | crafting-interpreters-89ffc2e60a7e7473504721874596e7bebcce896a.tar.gz crafting-interpreters-89ffc2e60a7e7473504721874596e7bebcce896a.zip |
Chapter 26.5
Diffstat (limited to 'clox/src/table.c')
-rw-r--r-- | clox/src/table.c | 9 |
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]; |