summaryrefslogtreecommitdiff
path: root/5.c
diff options
context:
space:
mode:
Diffstat (limited to '5.c')
-rw-r--r--5.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/5.c b/5.c
index f404440..993c555 100644
--- a/5.c
+++ b/5.c
@@ -13,6 +13,16 @@ struct crate {
};
+void
+crate_free(struct crate * c)
+{
+ if (!c)
+ return;
+ crate_free(c->next);
+ free(c);
+}
+
+
int
crates_move_9000(struct crate ** stack, int stacks, int dest, int src, int count)
{
@@ -78,6 +88,7 @@ crates_move_9001(struct crate ** stack, int stacks, int dest, int src, int count
}
+#ifdef CRATES_DUMP
int
crates_dump(struct crate ** stack, int stacks)
{
@@ -96,6 +107,7 @@ crates_dump(struct crate ** stack, int stacks)
return 0;
}
+#endif
int
@@ -184,6 +196,11 @@ main(int argc, char ** argv)
}
fputc('\n', stdout);
+ for (i = 0; i < stacks; ++i) {
+ crate_free(stack[i]);
+ }
+ free(stack);
+
return 0;
}