diff options
author | Warren Dukes <warren.dukes@gmail.com> | 2004-11-10 02:38:55 +0000 |
---|---|---|
committer | Warren Dukes <warren.dukes@gmail.com> | 2004-11-10 02:38:55 +0000 |
commit | 2d87ffa863b5eaa24862e925e767eb9a36bd58fe (patch) | |
tree | 98028112defc0aedfe282b88c8ba81b15ffdd53b /src/list.c | |
parent | 92a75471505391edd2f8f9af23188b4f7b17bbcb (diff) | |
download | mpd-2d87ffa863b5eaa24862e925e767eb9a36bd58fe.tar.gz mpd-2d87ffa863b5eaa24862e925e767eb9a36bd58fe.tar.xz mpd-2d87ffa863b5eaa24862e925e767eb9a36bd58fe.zip |
now we only allocate unique metadata items
git-svn-id: https://svn.musicpd.org/mpd/branches/r2562-metadata-handling-rewrite@2568 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src/list.c')
-rw-r--r-- | src/list.c | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/src/list.c b/src/list.c index c7d49397a..dad4093e6 100644 --- a/src/list.c +++ b/src/list.c @@ -104,7 +104,7 @@ int insertInListBeforeNode(List * list, ListNode * beforeNode, char * key, return 1; } -int insertInList(List * list,char * key,void * data) { +ListNode * insertInList(List * list,char * key,void * data) { ListNode * node; assert(list!=NULL); @@ -137,7 +137,7 @@ int insertInList(List * list,char * key,void * data) { list->numberOfNodes++; - return 1; + return node; } int insertInListWithoutKey(List * list, void * data) { @@ -173,7 +173,7 @@ int insertInListWithoutKey(List * list, void * data) { return 1; } -int findInList(List * list,char * key,void ** data) { +ListNode * findNodeInList(List * list, char * key) { static long high; static long low; static long cur; @@ -191,10 +191,7 @@ int findInList(List * list,char * key,void ** data) { cur = (high+low)/2; tmpNode = list->nodesArray[cur]; cmp = strcmp(tmpNode->key,key); - if(cmp==0) { - if(data) *data = tmpNode->data; - return 1; - } + if(cmp==0) return tmpNode; else if(cmp>0) high = cur; else { if(low==cur) break; @@ -205,10 +202,7 @@ int findInList(List * list,char * key,void ** data) { cur = high; if(cur>=0) { tmpNode = list->nodesArray[cur]; - if(strcmp(tmpNode->key,key)==0) { - (*data) = tmpNode->data; - return 1; - } + if(strcmp(tmpNode->key,key)==0) return tmpNode; } } else { @@ -218,10 +212,18 @@ int findInList(List * list,char * key,void ** data) { tmpNode = tmpNode->nextNode; } - if(tmpNode!=NULL) { - (*data) = tmpNode->data; - return 1; - } + if(tmpNode!=NULL) return tmpNode; + } + + return NULL; +} + +int findInList(List * list, char * key, void ** data) { + ListNode * node = findNodeInList(list, key); + + if(node) { + if(data) *data = node->data; + return 1; } return 0; |