Skip to content

Commit

Permalink
simplify recent bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
shawnl committed Apr 14, 2019
1 parent b49b00e commit bbfddaa
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/stringmap.c
Expand Up @@ -48,15 +48,13 @@ stringmap_t *stringmap_load(const char *filename, int numFinalWordsToMatch)
char buf[2*PATH_MAX];
int n;

fp = fopen(filename, "r");
if (!fp)
return NULL;
result = calloc(1, sizeof(*result));
if (!result)
return NULL;
result->numFinalWordsToMatch = numFinalWordsToMatch;
fp = fopen(filename, "r");
if (!fp) {
free(result);
return NULL;
}
n=0;
while (fgets(buf, sizeof(buf), fp))
n++;
Expand Down

0 comments on commit bbfddaa

Please sign in to comment.