diff options
author | Eric Wong <normalperson@yhbt.net> | 2006-07-16 16:50:54 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2006-07-16 16:50:54 +0000 |
commit | b59aa757205b2dc330d7864d88381c67beefb254 (patch) | |
tree | 382ba7b45c12d6115b828c8aaf76dac62e90120f | |
parent | 210ab3b9716b2cc3fa70e06011de143114c430b6 (diff) | |
download | mpd-b59aa757205b2dc330d7864d88381c67beefb254.tar.gz mpd-b59aa757205b2dc330d7864d88381c67beefb254.tar.xz mpd-b59aa757205b2dc330d7864d88381c67beefb254.zip |
remove the glib library dependency
We never used many features from it, so there's no point in
keeping it and forcing people to install a non-standard library.
It may be standard on many GNU/Linux distributions, but there
are many other UNIXes out there. This makes life much easier
for people cross-compiling (like me :)
git-svn-id: https://svn.musicpd.org/mpd/trunk@4361 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r-- | configure.ac | 3 | ||||
-rw-r--r-- | src/directory.c | 1 | ||||
-rw-r--r-- | src/list.c | 2 | ||||
-rw-r--r-- | src/list.h | 3 | ||||
-rw-r--r-- | src/tagTracker.c | 118 | ||||
-rw-r--r-- | src/tagTracker.h | 1 |
6 files changed, 59 insertions, 69 deletions
diff --git a/configure.ac b/configure.ac index 28ec9a53a..37a2e7933 100644 --- a/configure.ac +++ b/configure.ac @@ -89,9 +89,6 @@ AC_CHECK_LIB(nsl,gethostbyname,MPD_LIBS="$MPD_LIBS -lnsl",) AC_CHECK_LIB(m,exp,MPD_LIBS="$MPD_LIBS -lm",) AC_CHECK_FUNCS(setenv) -PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.0, [MPD_LIBS="$MPD_LIBS $GLIB_LIBS" MPD_CFLAGS="$MPD_CFLAGS $GLIB_CFLAGS"],[echo "";echo "** ERROR:Unable to find glib-2.0 of version 2.0 or above **" ; exit 1]) - - dnl doesn't work for systems that don't have CODESET like OpenBSD dnl AC_CHECK_HEADER(langinfo.h,[enable_langinfo=yes;AC_DEFINE(HAVE_LANGINFO,1,[Define if nl_langinfo.h is present])],enable_langinfo=no) diff --git a/src/directory.c b/src/directory.c index 16951dd30..1db1c862a 100644 --- a/src/directory.c +++ b/src/directory.c @@ -775,7 +775,6 @@ static int addToDirectory(Directory * directory, char * shortname, char * name) void closeMp3Directory() { freeDirectory(mp3rootDirectory); - destroyTagTracker(); } static Directory * findSubDirectory(Directory * directory,char * name) { diff --git a/src/list.c b/src/list.c index dc32e9c55..e681054fa 100644 --- a/src/list.c +++ b/src/list.c @@ -195,7 +195,7 @@ int insertInListWithoutKey(List * list, void * data) { /* if _key_ is not found, *_node_ is assigned to the node before which the info would be found */ -static int findNodeInList(List * list, char * key, ListNode ** node, int * pos) { +int findNodeInList(List * list, char * key, ListNode ** node, int * pos) { long high; long low; long cur; diff --git a/src/list.h b/src/list.h index 6d5f5e0c7..ec72561a4 100644 --- a/src/list.h +++ b/src/list.h @@ -97,6 +97,9 @@ void deleteNodeFromList(List * list,ListNode * node); */ int findInList(List * list, char * key, void ** data); +/* if _key_ is not found, *_node_ is assigned to the node before which + the info would be found */ +int findNodeInList(List * list, char * key, ListNode ** node, int * pos); /* frees memory malloc'd for list and its nodes * _list_ -> List to be free'd diff --git a/src/tagTracker.c b/src/tagTracker.c index 2d361fef0..14efb104b 100644 --- a/src/tagTracker.c +++ b/src/tagTracker.c @@ -18,13 +18,12 @@ #include "tagTracker.h" +#include "list.h" #include "log.h" -#include <glib/gtree.h> #include <assert.h> -#include <stdlib.h> -static GTree * tagLists[TAG_NUM_OF_ITEM_TYPES] = +static List * tagLists[TAG_NUM_OF_ITEM_TYPES] = { NULL, NULL, @@ -40,124 +39,117 @@ typedef struct tagTrackerItem { mpd_sint8 visited; } TagTrackerItem; -static int keyCompare(const void *a, const void *b, void *data) { - return strcmp(a,b); -} - char * getTagItemString(int type, char * string) { - TagTrackerItem * item; - TagTrackerItem ** itemPointer = &item; - char *key; - char **keyPointer = &key; + ListNode * node; + int pos; if(tagLists[type] == NULL) { - tagLists[type] = g_tree_new_full(keyCompare, NULL, free, free); + tagLists[type] = makeList(free, 1); + sortList(tagLists[type]); } - if((TagTrackerItem *)g_tree_lookup_extended(tagLists[type], string, (void**)keyPointer, (void**)itemPointer )) { - item->count++; + if(findNodeInList(tagLists[type], string, &node, &pos)) { + ((TagTrackerItem *)node->data)->count++; } else { - item = malloc(sizeof(TagTrackerItem)); + TagTrackerItem * item = malloc(sizeof(TagTrackerItem)); item->count = 1; item->visited = 0; - key = strdup(string); - g_tree_insert(tagLists[type], key, item); + node = insertInListBeforeNode(tagLists[type], node, pos, + string, item); } - return key; + return node->key; } - void removeTagItemString(int type, char * string) { - TagTrackerItem *item; + ListNode * node; + int pos; assert(string); assert(tagLists[type]); if(tagLists[type] == NULL) return; - if((item = g_tree_lookup(tagLists[type], string))) { + if(findNodeInList(tagLists[type], string, &node, &pos)) { + TagTrackerItem * item = node->data; item->count--; - if(item->count <= 0) g_tree_remove(tagLists[type], string); + if(item->count <= 0) deleteNodeFromList(tagLists[type], node); } -/* why would this be done??? free it when mpd quits... - if(tagLists[type]->numberOfNodes == 0) { + if(tagLists[type]->numberOfNodes == 0) { freeList(tagLists[type]); tagLists[type] = NULL; } -*/ -} - -void destroyTagTracker() { - int type; - for (type=0; type < TAG_NUM_OF_ITEM_TYPES; type ++) - if (tagLists[type]) - g_tree_destroy(tagLists[type]); } int getNumberOfTagItems(int type) { if(tagLists[type] == NULL) return 0; - return g_tree_nnodes(tagLists[type]); + return tagLists[type]->numberOfNodes; } -static int calcSavedMemory(char *key, TagTrackerItem* value, int* sum) { - *sum -= sizeof(int) + 4*sizeof(void*); /* sizeof(_GTreeNode) */ - *sum -= sizeof(TagTrackerItem); - *sum += (strlen(key)+1)*value->count; - return FALSE; -} - void printMemorySavedByTagTracker() { int i; + ListNode * node; size_t sum = 0; for(i = 0; i < TAG_NUM_OF_ITEM_TYPES; i++) { if(!tagLists[i]) continue; - sum -= 5*sizeof(void*);/* sizeof(_GTree) */ - g_tree_foreach(tagLists[i], (GTraverseFunc)calcSavedMemory, &sum); + sum -= sizeof(List); + + node = tagLists[i]->firstNode; + + while(node != NULL) { + sum -= sizeof(ListNode); + sum -= sizeof(TagTrackerItem); + sum -= sizeof(node->key); + sum += (strlen(node->key)+1)*(*((int *)node->data)); + node = node->nextNode; + } } DEBUG("saved memory from tags: %li\n", (long)sum); } -static int resetVisitedFlag(char *key, TagTrackerItem *value, void *data) { - value->visited = 0; - return FALSE; -} - void resetVisitedFlagsInTagTracker(int type) { + ListNode * node; if(!tagLists[type]) return; - g_tree_foreach(tagLists[type], (GTraverseFunc)resetVisitedFlag, NULL); + node = tagLists[type]->firstNode; + + while(node) { + ((TagTrackerItem *)node->data)->visited = 0; + node = node->nextNode; + } } void visitInTagTracker(int type, char * str) { - TagTrackerItem * item; + void * item; if(!tagLists[type]) return; - if(!(item = g_tree_lookup(tagLists[type], str))) return; - - item->visited = 1; -} - -struct _PrintVisitedUserdata { - FILE *fp; - char *type; -}; + if(!findInList(tagLists[type], str, &item)) return; -static int printVisitedFlag(char *key, TagTrackerItem* value, struct _PrintVisitedUserdata *data) { - if(value->visited) myfprintf(data->fp, "%s: %s\n", data->type, key); - return FALSE; + ((TagTrackerItem *)item)->visited = 1; } void printVisitedInTagTracker(FILE * fp, int type) { - struct _PrintVisitedUserdata data = {fp, mpdTagItemKeys[type]}; + ListNode * node; + TagTrackerItem * item; + if(!tagLists[type]) return; - g_tree_foreach( tagLists[type], (GTraverseFunc)printVisitedFlag, (void*)&data); + + node = tagLists[type]->firstNode; + + while(node) { + item = node->data; + if(item->visited) { + myfprintf(fp, "%s: %s\n", mpdTagItemKeys[type], + node->key); + } + node = node->nextNode; + } } diff --git a/src/tagTracker.h b/src/tagTracker.h index 51b195192..418ddf49e 100644 --- a/src/tagTracker.h +++ b/src/tagTracker.h @@ -24,7 +24,6 @@ char * getTagItemString(int type, char * string); void removeTagItemString(int type, char * string); -void destroyTagTracker(); int getNumberOfTagItems(int type); |