diff options
Diffstat (limited to 'src/tagTracker.c')
-rw-r--r-- | src/tagTracker.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/tagTracker.c b/src/tagTracker.c index 7bca526a7..23110c682 100644 --- a/src/tagTracker.c +++ b/src/tagTracker.c @@ -1,6 +1,7 @@ #include "tagTracker.h" #include "list.h" +#include "log.h" #include <assert.h> @@ -19,11 +20,12 @@ char * getTagItemString(int type, char * string) { ListNode * node; if(tagLists[type] == NULL) { - tagLists[type] = makeList(NULL); + tagLists[type] = makeList(free); } if((node = findNodeInList(tagLists[type], string))) { (*((int *)node->data))++; + printf("%s: %i\n", string, *((int *)node->data)); } else { int * intPtr = malloc(sizeof(int)); @@ -37,6 +39,8 @@ char * getTagItemString(int type, char * string) { void removeTagItemString(int type, char * string) { ListNode * node; + assert(tagLists[type]); + assert(string); if(tagLists[type] == NULL) return; node = findNodeInList(tagLists[type], string); @@ -58,3 +62,22 @@ int getNumberOfTagItems(int type) { return tagLists[type]->numberOfNodes; } + +void printMemorySavedByTagTracker() { + int i; + ListNode * node; + size_t sum = 0; + + for(i = 0; i < TAG_NUM_OF_ITEM_TYPES; i++) { + if(!tagLists[i]) continue; + + node = tagLists[i]->firstNode; + + while(node != NULL) { + sum += (strlen(node->key)+1)*(*((int *)node->data)); + node = node->nextNode; + } + } + + DEBUG("saved memory: %li\n", (long)sum); +} |