summaryrefslogtreecommitdiff
path: root/wk5/pset
diff options
context:
space:
mode:
authorFudgerboy <91767657+Fudgerboy@users.noreply.github.com>2024-04-28 22:15:03 +0000
committerFudgerboy <91767657+Fudgerboy@users.noreply.github.com>2024-04-28 22:15:03 +0000
commit26778d3989b4031882d15e64d3a34ae27d57f59f (patch)
tree93bb5bff7fee4406c2e6c8661eb17967e2fceee3 /wk5/pset
parenta9e28b785462a22e269a3375bc4de2468f6dee8c (diff)
Sun, Apr 28, 2024, 3:15 PM -07:00
Diffstat (limited to 'wk5/pset')
-rw-r--r--wk5/pset/speller/dictionary.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/wk5/pset/speller/dictionary.c b/wk5/pset/speller/dictionary.c
index c3111ea..929a93c 100644
--- a/wk5/pset/speller/dictionary.c
+++ b/wk5/pset/speller/dictionary.c
@@ -54,7 +54,12 @@ bool load(const char *dictionary)
char word[LENGTH + 1];
while(fscanf(source, "%s", word) != "E0F")
{
- malloc(sizefo(node));
+ char *ptr = malloc(sizefo(node));
+ if (ptr == NULL)
+ {
+ fclose(source);
+ return false;
+ }
}
/*
@@ -72,6 +77,7 @@ bool load(const char *dictionary)
// Close the dictionary file
fclose(source);
+ return true;
}
// Returns number of words in dictionary if loaded, else 0 if not yet loaded