From 6b4fea8d5ccbdcfb379da2ec512a1d238f459673 Mon Sep 17 00:00:00 2001 From: Avuton Olrich Date: Sat, 15 Jul 2006 03:34:48 +0000 Subject: [CLEANUP] Cleanup whitespace->tabs Remove dead code Static where possible git-svn-id: https://svn.musicpd.org/mpd/trunk@4345 09075e82-0dd4-0310-85a5-a0d7c8717e4f --- src/tagTracker.c | 40 ++++++------------------------- src/tagTracker.h | 4 ---- src/tree.c | 70 ------------------------------------------------------- src/tree.h | 71 -------------------------------------------------------- src/utils.c | 43 +++++++++++++++++----------------- src/volume.c | 60 +++++++++++++++++++++++------------------------ 6 files changed, 58 insertions(+), 230 deletions(-) delete mode 100644 src/tree.c delete mode 100644 src/tree.h diff --git a/src/tagTracker.c b/src/tagTracker.c index 81824b49c..2d361fef0 100644 --- a/src/tagTracker.c +++ b/src/tagTracker.c @@ -40,7 +40,7 @@ typedef struct tagTrackerItem { mpd_sint8 visited; } TagTrackerItem; -int keyCompare(const void *a, const void *b, void *data) { +static int keyCompare(const void *a, const void *b, void *data) { return strcmp(a,b); } @@ -49,9 +49,6 @@ char * getTagItemString(int type, char * string) { TagTrackerItem ** itemPointer = &item; char *key; char **keyPointer = &key; - - - /*if(type == TAG_ITEM_TITLE) return strdup(string);*/ if(tagLists[type] == NULL) { tagLists[type] = g_tree_new_full(keyCompare, NULL, free, free); @@ -66,8 +63,6 @@ char * getTagItemString(int type, char * string) { item->visited = 0; key = strdup(string); g_tree_insert(tagLists[type], key, item); - - } return key; @@ -97,7 +92,7 @@ void removeTagItemString(int type, char * string) { void destroyTagTracker() { int type; - for (type=0; type < TAG_NUM_OF_ITEM_TYPES; type ++) + for (type=0; type < TAG_NUM_OF_ITEM_TYPES; type ++) if (tagLists[type]) g_tree_destroy(tagLists[type]); } @@ -107,7 +102,8 @@ int getNumberOfTagItems(int type) { return g_tree_nnodes(tagLists[type]); } -int calcSavedMemory(char *key, TagTrackerItem* value, int* sum) { + +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; @@ -128,23 +124,11 @@ void printMemorySavedByTagTracker() { DEBUG("saved memory from tags: %li\n", (long)sum); } -void sortTagTrackerInfo() { - /* implicit sorting - int i; - - for(i = 0; i < TAG_NUM_OF_ITEM_TYPES; i++) { - if(!tagLists[i]) continue; - - DEBUG("sorting %s info\n", mpdTagItemKeys[i]); - - sortList(tagLists[i]); - }*/ -} - -int resetVisitedFlag(char *key, TagTrackerItem *value, void *data) { +static int resetVisitedFlag(char *key, TagTrackerItem *value, void *data) { value->visited = 0; return FALSE; } + void resetVisitedFlagsInTagTracker(int type) { if(!tagLists[type]) return; @@ -152,16 +136,6 @@ void resetVisitedFlagsInTagTracker(int type) { g_tree_foreach(tagLists[type], (GTraverseFunc)resetVisitedFlag, NULL); } -int wasVisitedInTagTracker(int type, char * str) { - TagTrackerItem * item; - - if(!tagLists[type]) return 0; - - if(!(item = g_tree_lookup(tagLists[type], str))) return 0; - - return item->visited; -} - void visitInTagTracker(int type, char * str) { TagTrackerItem * item; @@ -177,7 +151,7 @@ struct _PrintVisitedUserdata { char *type; }; -int printVisitedFlag(char *key, TagTrackerItem* value, struct _PrintVisitedUserdata *data) { +static int printVisitedFlag(char *key, TagTrackerItem* value, struct _PrintVisitedUserdata *data) { if(value->visited) myfprintf(data->fp, "%s: %s\n", data->type, key); return FALSE; } diff --git a/src/tagTracker.h b/src/tagTracker.h index 7cb9fa49a..51b195192 100644 --- a/src/tagTracker.h +++ b/src/tagTracker.h @@ -30,11 +30,7 @@ int getNumberOfTagItems(int type); void printMemorySavedByTagTracker(); -void sortTagTrackerInfo(); - void resetVisitedFlagsInTagTracker(int type); - -int wasVisitedInTagTracker(int type, char * str); void visitInTagTracker(int type, char * str); diff --git a/src/tree.c b/src/tree.c deleted file mode 100644 index 74dcb48d9..000000000 --- a/src/tree.c +++ /dev/null @@ -1,70 +0,0 @@ -/* the Music Player Daemon (MPD) - * (c)2003-2006 by Warren Dukes (warren.dukes@gmail.com) - * This project's homepage is: http://www.musicpd.org - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "tree.h" - -static inline TreeNode * newTreeNode() { - TreeNode * ret = malloc(sizeof(TreeNode)); - - ret->data[0] = NULL; - ret->data[1] = NULL; - - ret->children[0] = NULL; - ret->children[1] = NULL; - ret->children[2] = NULL; - - return ret; -} - -static inline void freeTreeNode(TreeNode * node) { - free(node); -} - -Tree * newTree(TreeFreeDataFunc * freeFunc, TreeCompareDataFunc * compareFunc) { - Tree * ret = malloc(sizeof(Tree)); - - ret->headNode = NULL; - ret->freeFunc = freeFunc; - ret->compareFunc = compareFunc; - - return ret; -} - -void freeTree(Tree * tree) { - TreeIterator * iter = newTreeIterator(tree, POSTORDER); - - TreeNode * node; - - if(data->freeFunc) { - void * data; - - while( ( data = nextTreeIterator(iter) ) ) { - - } - - freeTreeIterator(iter); - - iter = newTreeIterator(tree, POSTORDER); - } - - while( ( node = nextNodeTreeIterator(iter) ) ) { - freeTreeNode(node); - } - - freeTreeIterator(iter); -} diff --git a/src/tree.h b/src/tree.h deleted file mode 100644 index 7976cac8c..000000000 --- a/src/tree.h +++ /dev/null @@ -1,71 +0,0 @@ -/* the Music Player Daemon (MPD) - * (c)2003-2006 by Warren Dukes (warren.dukes@gmail.com) - * This project's homepage is: http://www.musicpd.org - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef TREE_H -#define TREE_H - -typedef struct _TreeNode { - void * data[2]; - struct _TreeNode * children[3]; - struct _TreeNode * parent; -} TreeNode; - -typedef struct _Tree { - TreeNode headNode; - TreeFreeDataFunc * freeFunc; - TreeCompareDataFunc * compareFunc; -} Tree; - -typedef enum _TreeIteratorType { - PREORDER, - INORDER, - POSTORDER -} TreeIteratorType; - -typedef struct _TreeIterator { - Data * data; - /* private data */ - TreeIteratorType type; - TreeNode * currentNode; - int pos; -} TreeIterator; - -typedef int TreeCompareDataFunc(void * left, void * right); - -typedef int TreeFreeDataFunc(void * data); - -Tree * newTree(TreeFreeDataFunc * freeFunc, TreeCompareDataFunc * compareFunc); - -void freeTree(Tree * tree); - -int insertInTree(Tree * tree, void * data); - -int deleteFromTree(Tree * tree, void * needle); - -void * findInTree(Tree * tree, void * needle); - -TreeIterator * newTreeIterator(Tree * tree, TreeIteratorType type); - -/* will return the same pointer passed in on success - * if NULL is returned, this indicates the end of tree - */ -data * nextTreeIterator(TreeIterator * iter); - -void freeTreeIterator(TreeIterator * iter); - -#endif /* TREE_H */ diff --git a/src/utils.c b/src/utils.c index 6cc66e379..7dbe88833 100644 --- a/src/utils.c +++ b/src/utils.c @@ -41,9 +41,9 @@ char * myFgets(char * buffer, int bufferSize, FILE * fp) { char * strDupToUpper(char * str) { char * ret = strdup(str); int i; - + for(i=0;ivalue; @@ -250,11 +250,11 @@ int prepAlsaMixer(char * card) { return -1; } -void closeAlsaMixer() { +static void closeAlsaMixer() { snd_mixer_close(volume_alsaMixerHandle); } -int getAlsaVolumeLevel() { +static int getAlsaVolumeLevel() { int ret; long level; long max = volume_alsaMax; @@ -280,7 +280,7 @@ int getAlsaVolumeLevel() { return ret; } -int changeAlsaVolumeLevel(FILE * fp, int change, int rel) { +static int changeAlsaVolumeLevel(FILE * fp, int change, int rel) { float vol; long level; long test; @@ -329,7 +329,7 @@ int changeAlsaVolumeLevel(FILE * fp, int change, int rel) { } #endif -int prepMixer(char * device) { +static int prepMixer(char * device) { switch(volume_mixerType) { #ifdef HAVE_ALSA case VOLUME_MIXER_TYPE_ALSA: @@ -360,9 +360,9 @@ void finishVolume() { } void initVolume() { - ConfigParam * param = getConfigParam(CONF_MIXER_TYPE); + ConfigParam * param = getConfigParam(CONF_MIXER_TYPE); - if(param) { + if(param) { if(0); #ifdef HAVE_ALSA else if(strcmp(param->value, VOLUME_MIXER_ALSA)==0) { @@ -388,7 +388,7 @@ void initVolume() { } param = getConfigParam(CONF_MIXER_DEVICE); - + if(param) { volume_mixerDevice = param->value; } @@ -401,7 +401,7 @@ void openVolumeDevice() { } } -int getSoftwareVolume() { +static int getSoftwareVolume() { return volume_softwareSet; } @@ -422,7 +422,7 @@ int getVolumeLevel() { } } -int changeSoftwareVolume(FILE * fp, int change, int rel) { +static int changeSoftwareVolume(FILE * fp, int change, int rel) { int new = change; if(rel) new+=volume_softwareSet; @@ -455,7 +455,7 @@ int changeVolumeLevel(FILE * fp, int change, int rel) { case VOLUME_MIXER_TYPE_SOFTWARE: return changeSoftwareVolume(fp,change,rel); default: - return 0; - break; + return 0; + break; } } -- cgit v1.2.3