don't free nodes too early

This commit is contained in:
Connor Olding 2012-08-28 18:02:00 -07:00
parent cf1df4e226
commit a6ee682ae8
1 changed files with 11 additions and 1 deletions

12
main.c
View File

@ -162,6 +162,16 @@ static void print_crc(ulong remainder)
printf("%08X\n", (int) remainder);
}
static void free_nodes(string_node *n)
{
string_node *next;
while (n) {
next = n->next;
free(n);
n = next;
}
}
int main(int argc, char **argv)
{
string_node *n;
@ -175,7 +185,7 @@ int main(int argc, char **argv)
FILE *stream = open_stream(n->s);
print_crc(cycle_file(stream));
fclose(stream);
free(n);
}
free_nodes(input_node);
return 0;
}