diff options
author | Warren Dukes <warren.dukes@gmail.com> | 2004-04-10 02:55:27 +0000 |
---|---|---|
committer | Warren Dukes <warren.dukes@gmail.com> | 2004-04-10 02:55:27 +0000 |
commit | 918dc2ff22e13808665b589e6740f45256e73c97 (patch) | |
tree | 7f694c3312b7115d869f50ad3f344a2e04e36672 | |
parent | 9b5f32c9e542bc8d67934866a58af37a12fb18fe (diff) | |
download | mpd-918dc2ff22e13808665b589e6740f45256e73c97.tar.gz mpd-918dc2ff22e13808665b589e6740f45256e73c97.tar.xz mpd-918dc2ff22e13808665b589e6740f45256e73c97.zip |
ideas on how to make readDirectoryInfo and readSongInfo deal with already
existing db stuff, and implement a new List function that will be very
useful: insertInListBeforeNode()
git-svn-id: https://svn.musicpd.org/mpd/trunk@657 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r-- | TODO | 1 | ||||
-rw-r--r-- | src/list.c | 45 | ||||
-rw-r--r-- | src/list.h | 3 |
3 files changed, 49 insertions, 0 deletions
@@ -6,6 +6,7 @@ e) add an element to status stating the "update state" f) store stuff to updated in a linked list prior to update fork g) update child writes db file, parents reads db file when done (the msells/sbh alogrithm) + h) when reading directory db and checking for deleted, new, or changed stuff, assume all info is sorted (so we can deterimine if its new very quickly without searching through lists of stuff every time). Also, for new stuff, insert it with insertInListBeforeNode() function, to keep lists sorted. 2) rewrite interface stuff, specifically command list handling etc so its less of a hack and deals with the above update stuff better diff --git a/src/list.c b/src/list.c index 8ce872fc2..d14f5b874 100644 --- a/src/list.c +++ b/src/list.c @@ -56,6 +56,51 @@ List * makeList(ListFreeDataFunc * freeDataFunc) { return list; } +int insertInListBeforeNode(List * list, ListNode * beforeNode, char * key, + void * data) +{ + ListNode * node; + + assert(list!=NULL); + assert(key!=NULL); + /*assert(data!=NULL);*/ + + node = malloc(sizeof(ListNode)); + assert(node!=NULL); + + if(list->nodesArray) freeListNodesArray(list); + + if(beforeNode==NULL) beforeNode = list->firstNode; + + node->nextNode = beforeNode; + if(beforeNode==list->firstNode) { + if(list->firstNode==NULL) { + assert(list->lastNode==NULL); + list->lastNode = node; + } + else { + assert(list->lastNode!=NULL); + assert(list->lastNode->nextNode==NULL); + list->firstNode->prevNode = node; + } + node->prevNode = NULL; + list->firstNode = node; + } + else { + node->prevNode = beforeNode->prevNode; + beforeNode->prevNode = node; + } + + node->key = malloc((strlen(key)+1)*sizeof(char)); + assert(node->key!=NULL); + strcpy(node->key,key); + node->data = data; + + list->numberOfNodes++; + + return 1; +} + int insertInList(List * list,char * key,void * data) { ListNode * node; diff --git a/src/list.h b/src/list.h index 4ae32160a..14f7f396b 100644 --- a/src/list.h +++ b/src/list.h @@ -69,6 +69,9 @@ List * makeList(ListFreeDataFunc * freeDataFunc); */ int insertInList(List * list,char * key,void * data); +int insertInListBeforeNode(List * list, ListNode * beforeNode, char * key, + void * data); + int insertInListWithoutKey(List * list,void * data); /* deletes the first node in the list with the key _key_ |