diff options
Diffstat (limited to 'wk5/pset')
-rw-r--r-- | wk5/pset/speller/dictionary.c | 8 |
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 |