ModSim: Minor bug fix in assignment 2.7

parent 5e94d2c1
......@@ -10,6 +10,7 @@ q%: q%.o
%.o: %.c
$(CC) $(CFLAGS) -o $@ -c $^
.PHONY: clean
clean:
for i in `seq 7`; do \
rm -vf q$$i; \
......
......@@ -7,7 +7,7 @@
#include <assert.h>
typedef struct rabbit {
int age;
unsigned short age;
struct rabbit *prev, *next;
} rabbit;
......@@ -38,7 +38,7 @@ void rabbit_die(rabbit **ptr) {
r->next->prev = r->prev;
if( r == rabbits )
rabbits = NULL;
rabbits = r->next;
*ptr = NULL;
rabbit_count--;
......@@ -69,7 +69,6 @@ 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