ModSim: assignment 2.7 does not free() all rabbits.

parent d167a381
CC=clang
CFLAGS=-Wall -Wextra -pedantic -std=c99 -D_GNU_SOURCE
CFLAGS=-Wall -Wextra -pedantic -std=c99 -D_GNU_SOURCE -g
LFLAGS=-lm
all: q1 q2 q3 q4 q5 q7
......
......@@ -4,6 +4,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
typedef struct rabbit {
int age;
......@@ -20,6 +21,7 @@ rabbit *rabbit_born() {
rabbits->prev = r;
r->age = 0;
r->prev = NULL;
rabbits = r;
rabbit_count++;
......@@ -67,6 +69,7 @@ void sequence(int generations, int max_age) {
puts("");
// This does not free() all rabbits
while( rabbits )
rabbit_die(&rabbits);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment