aboutsummaryrefslogtreecommitdiffstats
path: root/src/tagTracker.c
diff options
context:
space:
mode:
authorWarren Dukes <warren.dukes@gmail.com>2004-11-10 21:48:08 +0000
committerWarren Dukes <warren.dukes@gmail.com>2004-11-10 21:48:08 +0000
commit021a0915c2bc6e62bda3e45a89c95266f3b2da47 (patch)
treec789eb800bfb04d5934728a327c5dd90c569e21c /src/tagTracker.c
parent0337ec851c643503afd2287f03ca42b5adf5cad7 (diff)
downloadmpd-021a0915c2bc6e62bda3e45a89c95266f3b2da47.tar.gz
mpd-021a0915c2bc6e62bda3e45a89c95266f3b2da47.tar.xz
mpd-021a0915c2bc6e62bda3e45a89c95266f3b2da47.zip
ok, list is now reimplemented, should be ready to go, this branch is now
compatible with trunk mpd again, time merge git-svn-id: https://svn.musicpd.org/mpd/branches/r2562-metadata-handling-rewrite@2587 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src/tagTracker.c')
-rw-r--r--src/tagTracker.c53
1 files changed, 45 insertions, 8 deletions
diff --git a/src/tagTracker.c b/src/tagTracker.c
index cea02f471..30ae7641b 100644
--- a/src/tagTracker.c
+++ b/src/tagTracker.c
@@ -16,6 +16,11 @@ static List * tagLists[TAG_NUM_OF_ITEM_TYPES] =
NULL
};
+typedef struct tagTrackerItem {
+ int count;
+ mpd_sint8 visited;
+} TagTrackerItem;
+
char * getTagItemString(int type, char * string) {
ListNode * node;
@@ -26,12 +31,13 @@ char * getTagItemString(int type, char * string) {
}
if((node = findNodeInList(tagLists[type], string))) {
- (*((int *)node->data))++;
+ ((TagTrackerItem *)node->data)->count++;
}
else {
- int * intPtr = malloc(sizeof(int));
- *intPtr = 1;
- node = insertInList(tagLists[type], string, intPtr);
+ TagTrackerItem * item = malloc(sizeof(TagTrackerItem));
+ item->count = 1;
+ item->visited = 0;
+ node = insertInList(tagLists[type], string, item);
}
return node->key;
@@ -53,9 +59,9 @@ void removeTagItemString(int type, char * string) {
node = findNodeInList(tagLists[type], string);
assert(node);
if(node) {
- int * countPtr = node->data;
- (*countPtr)--;
- if(*countPtr <= 0) deleteNodeFromList(tagLists[type], node);
+ TagTrackerItem * item = node->data;
+ item->count--;
+ if(item->count <= 0) deleteNodeFromList(tagLists[type], node);
}
if(tagLists[type]->numberOfNodes == 0) {
@@ -84,7 +90,7 @@ void printMemorySavedByTagTracker() {
while(node != NULL) {
sum -= sizeof(ListNode);
- sum -= sizeof(int);
+ sum -= sizeof(TagTrackerItem);
sum -= sizeof(node->key);
sum += (strlen(node->key)+1)*(*((int *)node->data));
node = node->nextNode;
@@ -103,3 +109,34 @@ void sortTagTrackerInfo() {
sortList(tagLists[i]);
}
}
+
+void resetVisitedFlagsInTagTracker(int type) {
+ ListNode * node;
+
+ if(!tagLists[type]) return;
+
+ node = tagLists[type]->firstNode;
+
+ while(node) {
+ ((TagTrackerItem *)node->data)->visited = 0;
+ node = node->nextNode;
+ }
+}
+
+int wasVisitedInTagTracker(int type, char * str) {
+ int ret;
+ ListNode * node;
+ TagTrackerItem * item;
+
+ if(!tagLists[type]) return 0;
+
+ node = findNodeInList(tagLists[type], str);
+
+ if(!node) return 0;
+
+ item = node->data;
+ ret = item->visited;
+ item->visited = 1;
+
+ return ret;
+}