15-213 Recitation 8 – 3/12/01Outline• Memory Allocation– Lab 3 DetailsShaheen Gandhie-mail:[email protected] Hours:Wednesday 1:30 – 2:30Wean 3108Reminders• Lab 3: Conservative Garbage Collector• Checkpoint Due 3/13• Lab Due 3/21• At least there’s nothing over Spring Break (I think)Conservative Garbage Collection:An Exampletypedef struct node{struct node *next;} Node;void taste(Node *h){Node *n = h;h = malloc(sizeof(Node));h->next = n;}void srees(Node **h){Node *n = *h;*h = (*h)->next;}Node *head = malloc(sizeof(Node));head->next = malloc(sizeof(Node));taste(head);srees(&head);taste() leaks memoryLab 3 Tips• Start Early– Checkpoint Wednesday– You need a working collector by then• Read the Lab handout– Now read it again• Don’t write any code until you know what you want to do• Review Pointer Arithmetic• Use gdb to your advantage– Condition breakpoints, for
View Full Document