diff tree7/Makefile tree8/Makefile 1a2 > # (added memory module, -DTESTING for tree.c) 6c7 < CFLAGS = -Wall -pedantic -std=c11 -ggdb --- > CFLAGS = -Wall -pedantic -std=c11 -ggdb -DTESTING 8c9 < OBJS = treetest.o tree.o --- > OBJS = treetest.o tree.o memory.o 15c16,17 < tree.o: tree.h --- > tree.o: tree.h memory.h > memory.o: memory.h Only in tree8: memory.c Only in tree8: memory.h diff tree7/tree.c tree8/tree.c 3c3 < * (version 7: add tree_delete) --- > * (version 8: add malloc/free tracking) 11a12 > #include "memory.h" 13c14 < /**************** global variables ****************/ --- > /**************** file-local global variables ****************/ 39a41 > 47c49 < tree_t *tree = malloc(sizeof(tree_t)); --- > tree_t *tree = count_malloc(sizeof(tree_t)); 64a67,70 > > #ifdef TESTING > count_report(stdout, "After tree_insert"); > #endif 99c105 < treenode_t *node = malloc(sizeof(treenode_t)); --- > treenode_t *node = count_malloc(sizeof(treenode_t)); 105c111 < node->key = malloc(strlen(key)+1); --- > node->key = count_malloc(strlen(key)+1); 109c115 < free(node); --- > count_free(node); 194c200,204 < free(tree); --- > count_free(tree); > > #ifdef TESTING > count_report(stdout, "End of tree_delete"); > #endif 215,216c225,226 < free(node->key); < free(node); --- > count_free(node->key); > count_free(node); diff tree7/treetest.c tree8/treetest.c 48c48 < printf("\ndelete the tree..."); --- > printf("\ndelete the tree...\n");