diff options
author | Warren Dukes <warren.dukes@gmail.com> | 2004-11-11 13:15:41 +0000 |
---|---|---|
committer | Warren Dukes <warren.dukes@gmail.com> | 2004-11-11 13:15:41 +0000 |
commit | b9272fa95a2db87d499fde531124a977f62e194e (patch) | |
tree | 32d3f0e6b43c119ced5cb8d051fb0abd97b2883b /src/tagTracker.c | |
parent | 1d123cd496bd9c01586dcb8d75f48fc3c5e74532 (diff) | |
download | mpd-b9272fa95a2db87d499fde531124a977f62e194e.tar.gz mpd-b9272fa95a2db87d499fde531124a977f62e194e.tar.xz mpd-b9272fa95a2db87d499fde531124a977f62e194e.zip |
ok, tagtracker now tracks title, this has the disadvantage of needing to sort
the title tracker list, and it wastes more memory.
But it makes implementing list command elegant, since we've just visit tags,
then print out the visited tags in tag tracker (which has the benefit of
making sure everything is in sorted order)
git-svn-id: https://svn.musicpd.org/mpd/trunk@2608 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src/tagTracker.c')
-rw-r--r-- | src/tagTracker.c | 43 |
1 files changed, 30 insertions, 13 deletions
diff --git a/src/tagTracker.c b/src/tagTracker.c index b7608ed97..e2594341d 100644 --- a/src/tagTracker.c +++ b/src/tagTracker.c @@ -24,8 +24,6 @@ typedef struct tagTrackerItem { char * getTagItemString(int type, char * string) { ListNode * node; - if(type == TAG_ITEM_TITLE) return strdup(string); - if(tagLists[type] == NULL) { tagLists[type] = makeList(free, 1); } @@ -48,11 +46,6 @@ void removeTagItemString(int type, char * string) { assert(string); - if(type == TAG_ITEM_TITLE) { - free(string); - return; - } - assert(tagLists[type]); if(tagLists[type] == NULL) return; @@ -124,9 +117,7 @@ void resetVisitedFlagsInTagTracker(int type) { } int wasVisitedInTagTracker(int type, char * str) { - int ret; ListNode * node; - TagTrackerItem * item; if(!tagLists[type]) return 0; @@ -134,9 +125,35 @@ int wasVisitedInTagTracker(int type, char * str) { if(!node) return 0; - item = node->data; - ret = item->visited; - item->visited = 1; + return ((TagTrackerItem *)node->data)->visited; +} + +void visitInTagTracker(int type, char * str) { + ListNode * node; + + if(!tagLists[type]) return; + + node = findNodeInList(tagLists[type], str); - return ret; + if(!node) return; + + ((TagTrackerItem *)node->data)->visited = 1; } + +void printVisitedInTagTracker(FILE * fp, int type) { + ListNode * node; + TagTrackerItem * item; + + if(!tagLists[type]) return; + + node = tagLists[type]->firstNode; + + while(node) { + item = node->data; + if(item->visited) { + myfprintf(fp, "%s: %s\n", mpdTagItemKeys[type], + node->key); + } + node = node->nextNode; + } + |