summaryrefslogtreecommitdiff
path: root/wk5/pset/speller/dictionary.c
diff options
context:
space:
mode:
authorFudgerboy <91767657+Fudgerboy@users.noreply.github.com>2024-04-29 03:09:00 +0000
committerFudgerboy <91767657+Fudgerboy@users.noreply.github.com>2024-04-29 03:09:00 +0000
commita6152288a590c5377ef0fab1e445f4a9bec0a022 (patch)
tree9710c69d00294fdb1c35e254046fcfe68cfde807 /wk5/pset/speller/dictionary.c
parent5bfc7e361ad922f2290985387dbec6a37ab00ced (diff)
Sun, Apr 28, 2024, 8:09 PM -07:00
Diffstat (limited to 'wk5/pset/speller/dictionary.c')
-rw-r--r--wk5/pset/speller/dictionary.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/wk5/pset/speller/dictionary.c b/wk5/pset/speller/dictionary.c
index e984b9f..75cfe8c 100644
--- a/wk5/pset/speller/dictionary.c
+++ b/wk5/pset/speller/dictionary.c
@@ -102,6 +102,20 @@ unsigned int size(void)
// Unloads dictionary from memory, returning true if successful, else false
bool unload(void)
{
- // TODO
- return false;
+ // for every bucket
+ for (int i = 0; i < N; i++)
+ {
+ // while there's more in the bucket
+ node *current = table[i];
+ while (current != NULL)
+ {
+ // record position of this node
+ node *this = current;
+ // record position of next node
+ current = current->next;
+ // free this node
+ free(this);
+ }
+ }
+ return true;
}