[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
This commit is contained in:
Avuton Olrich 2006-07-15 03:34:48 +00:00
parent d0c08c5218
commit 6b4fea8d5c
6 changed files with 58 additions and 230 deletions

View File

@ -40,7 +40,7 @@ typedef struct tagTrackerItem {
mpd_sint8 visited; mpd_sint8 visited;
} TagTrackerItem; } 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); return strcmp(a,b);
} }
@ -49,9 +49,6 @@ char * getTagItemString(int type, char * string) {
TagTrackerItem ** itemPointer = &item; TagTrackerItem ** itemPointer = &item;
char *key; char *key;
char **keyPointer = &key; char **keyPointer = &key;
/*if(type == TAG_ITEM_TITLE) return strdup(string);*/
if(tagLists[type] == NULL) { if(tagLists[type] == NULL) {
tagLists[type] = g_tree_new_full(keyCompare, NULL, free, free); tagLists[type] = g_tree_new_full(keyCompare, NULL, free, free);
@ -66,8 +63,6 @@ char * getTagItemString(int type, char * string) {
item->visited = 0; item->visited = 0;
key = strdup(string); key = strdup(string);
g_tree_insert(tagLists[type], key, item); g_tree_insert(tagLists[type], key, item);
} }
return key; return key;
@ -97,7 +92,7 @@ void removeTagItemString(int type, char * string) {
void destroyTagTracker() { void destroyTagTracker() {
int type; 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]) if (tagLists[type])
g_tree_destroy(tagLists[type]); g_tree_destroy(tagLists[type]);
} }
@ -107,7 +102,8 @@ int getNumberOfTagItems(int type) {
return g_tree_nnodes(tagLists[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(int) + 4*sizeof(void*); /* sizeof(_GTreeNode) */
*sum -= sizeof(TagTrackerItem); *sum -= sizeof(TagTrackerItem);
*sum += (strlen(key)+1)*value->count; *sum += (strlen(key)+1)*value->count;
@ -128,23 +124,11 @@ void printMemorySavedByTagTracker() {
DEBUG("saved memory from tags: %li\n", (long)sum); DEBUG("saved memory from tags: %li\n", (long)sum);
} }
void sortTagTrackerInfo() { static int resetVisitedFlag(char *key, TagTrackerItem *value, void *data) {
/* 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) {
value->visited = 0; value->visited = 0;
return FALSE; return FALSE;
} }
void resetVisitedFlagsInTagTracker(int type) { void resetVisitedFlagsInTagTracker(int type) {
if(!tagLists[type]) return; if(!tagLists[type]) return;
@ -152,16 +136,6 @@ void resetVisitedFlagsInTagTracker(int type) {
g_tree_foreach(tagLists[type], (GTraverseFunc)resetVisitedFlag, NULL); 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) { void visitInTagTracker(int type, char * str) {
TagTrackerItem * item; TagTrackerItem * item;
@ -177,7 +151,7 @@ struct _PrintVisitedUserdata {
char *type; 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); if(value->visited) myfprintf(data->fp, "%s: %s\n", data->type, key);
return FALSE; return FALSE;
} }

View File

@ -30,11 +30,7 @@ int getNumberOfTagItems(int type);
void printMemorySavedByTagTracker(); void printMemorySavedByTagTracker();
void sortTagTrackerInfo();
void resetVisitedFlagsInTagTracker(int type); void resetVisitedFlagsInTagTracker(int type);
int wasVisitedInTagTracker(int type, char * str);
void visitInTagTracker(int type, char * str); void visitInTagTracker(int type, char * str);

View File

@ -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);
}

View File

@ -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 */

View File

@ -41,9 +41,9 @@ char * myFgets(char * buffer, int bufferSize, FILE * fp) {
char * strDupToUpper(char * str) { char * strDupToUpper(char * str) {
char * ret = strdup(str); char * ret = strdup(str);
int i; int i;
for(i=0;i<strlen(str);i++) ret[i] = toupper((int)ret[i]); for(i=0;i<strlen(str);i++) ret[i] = toupper((int)ret[i]);
return ret; return ret;
} }
@ -74,29 +74,28 @@ int ipv6Supported() {
} }
char * appendToString(char * dest, const char * src) { char * appendToString(char * dest, const char * src) {
int destlen; int destlen;
int srclen = strlen(src); int srclen = strlen(src);
if(dest == NULL) { if(dest == NULL) {
dest = malloc(srclen+1); dest = malloc(srclen+1);
memset(dest, 0, srclen+1); memset(dest, 0, srclen+1);
destlen = 0; destlen = 0;
} }
else { else {
destlen = strlen(dest); destlen = strlen(dest);
dest = realloc(dest, destlen+srclen+1); dest = realloc(dest, destlen+srclen+1);
} }
memcpy(dest+destlen, src, srclen); memcpy(dest+destlen, src, srclen);
dest[destlen+srclen] = '\0'; dest[destlen+srclen] = '\0';
return dest; return dest;
} }
unsigned long readLEuint32(const unsigned char *p) unsigned long readLEuint32(const unsigned char *p)
{ {
return ((unsigned long) p[0] << 0) | return ((unsigned long) p[0] << 0) |
((unsigned long) p[1] << 8) | ((unsigned long) p[1] << 8) |
((unsigned long) p[2] << 16) | ((unsigned long) p[3] << 24); ((unsigned long) p[2] << 16) | ((unsigned long) p[3] << 24);
} }

View File

@ -58,28 +58,28 @@
#endif #endif
#endif #endif
int volume_mixerType = VOLUME_MIXER_TYPE_DEFAULT; static int volume_mixerType = VOLUME_MIXER_TYPE_DEFAULT;
char * volume_mixerDevice = VOLUME_MIXER_DEVICE_DEFAULT; static char * volume_mixerDevice = VOLUME_MIXER_DEVICE_DEFAULT;
int volume_softwareSet = 100; static int volume_softwareSet = 100;
#ifdef HAVE_OSS #ifdef HAVE_OSS
int volume_ossFd; static int volume_ossFd;
int volume_ossControl = SOUND_MIXER_PCM; static int volume_ossControl = SOUND_MIXER_PCM;
#endif #endif
#ifdef HAVE_ALSA #ifdef HAVE_ALSA
snd_mixer_t * volume_alsaMixerHandle = NULL; static snd_mixer_t * volume_alsaMixerHandle = NULL;
snd_mixer_elem_t * volume_alsaElem; static snd_mixer_elem_t * volume_alsaElem;
long volume_alsaMin; static long volume_alsaMin;
long volume_alsaMax; static long volume_alsaMax;
int volume_alsaSet = -1; static int volume_alsaSet = -1;
#endif #endif
#ifdef HAVE_OSS #ifdef HAVE_OSS
int prepOssMixer(char * device) { static int prepOssMixer(char * device) {
int devmask = 0; int devmask = 0;
ConfigParam * param; ConfigParam * param;
if((volume_ossFd = open(device,O_RDONLY))<0) { if((volume_ossFd = open(device,O_RDONLY))<0) {
WARNING("unable to open oss mixer \"%s\"\n",device); WARNING("unable to open oss mixer \"%s\"\n",device);
@ -130,11 +130,11 @@ int prepOssMixer(char * device) {
return 0; return 0;
} }
void closeOssMixer() { static void closeOssMixer() {
close(volume_ossFd); close(volume_ossFd);
} }
int getOssVolumeLevel() { static int getOssVolumeLevel() {
int left, right, level; int left, right, level;
if(ioctl(volume_ossFd,MIXER_READ(volume_ossControl),&level) < 0) { if(ioctl(volume_ossFd,MIXER_READ(volume_ossControl),&level) < 0) {
@ -153,7 +153,7 @@ int getOssVolumeLevel() {
return left; return left;
} }
int changeOssVolumeLevel(FILE * fp, int change, int rel) { static int changeOssVolumeLevel(FILE * fp, int change, int rel) {
int current; int current;
int new; int new;
int level; int level;
@ -185,7 +185,7 @@ int changeOssVolumeLevel(FILE * fp, int change, int rel) {
#endif #endif
#ifdef HAVE_ALSA #ifdef HAVE_ALSA
int prepAlsaMixer(char * card) { static int prepAlsaMixer(char * card) {
int err; int err;
snd_mixer_elem_t * elem; snd_mixer_elem_t * elem;
char * controlName = VOLUME_MIXER_ALSA_CONTROL_DEFAULT; char * controlName = VOLUME_MIXER_ALSA_CONTROL_DEFAULT;
@ -195,14 +195,14 @@ int prepAlsaMixer(char * card) {
WARNING("problems opening alsa mixer: %s\n",snd_strerror(err)); WARNING("problems opening alsa mixer: %s\n",snd_strerror(err));
return -1; return -1;
} }
if((err = snd_mixer_attach(volume_alsaMixerHandle,card))<0) { if((err = snd_mixer_attach(volume_alsaMixerHandle,card))<0) {
snd_mixer_close(volume_alsaMixerHandle); snd_mixer_close(volume_alsaMixerHandle);
WARNING("problems problems attaching alsa mixer: %s\n", WARNING("problems problems attaching alsa mixer: %s\n",
snd_strerror(err)); snd_strerror(err));
return -1; return -1;
} }
if((err = snd_mixer_selem_register(volume_alsaMixerHandle,NULL,NULL))<0) { if((err = snd_mixer_selem_register(volume_alsaMixerHandle,NULL,NULL))<0) {
snd_mixer_close(volume_alsaMixerHandle); snd_mixer_close(volume_alsaMixerHandle);
WARNING("problems snd_mixer_selem_register'ing: %s\n", WARNING("problems snd_mixer_selem_register'ing: %s\n",
@ -219,7 +219,7 @@ int prepAlsaMixer(char * card) {
elem = snd_mixer_first_elem(volume_alsaMixerHandle); elem = snd_mixer_first_elem(volume_alsaMixerHandle);
param = getConfigParam(CONF_MIXER_CONTROL); param = getConfigParam(CONF_MIXER_CONTROL);
if(param) { if(param) {
controlName = param->value; controlName = param->value;
@ -250,11 +250,11 @@ int prepAlsaMixer(char * card) {
return -1; return -1;
} }
void closeAlsaMixer() { static void closeAlsaMixer() {
snd_mixer_close(volume_alsaMixerHandle); snd_mixer_close(volume_alsaMixerHandle);
} }
int getAlsaVolumeLevel() { static int getAlsaVolumeLevel() {
int ret; int ret;
long level; long level;
long max = volume_alsaMax; long max = volume_alsaMax;
@ -280,7 +280,7 @@ int getAlsaVolumeLevel() {
return ret; return ret;
} }
int changeAlsaVolumeLevel(FILE * fp, int change, int rel) { static int changeAlsaVolumeLevel(FILE * fp, int change, int rel) {
float vol; float vol;
long level; long level;
long test; long test;
@ -329,7 +329,7 @@ int changeAlsaVolumeLevel(FILE * fp, int change, int rel) {
} }
#endif #endif
int prepMixer(char * device) { static int prepMixer(char * device) {
switch(volume_mixerType) { switch(volume_mixerType) {
#ifdef HAVE_ALSA #ifdef HAVE_ALSA
case VOLUME_MIXER_TYPE_ALSA: case VOLUME_MIXER_TYPE_ALSA:
@ -360,9 +360,9 @@ void finishVolume() {
} }
void initVolume() { void initVolume() {
ConfigParam * param = getConfigParam(CONF_MIXER_TYPE); ConfigParam * param = getConfigParam(CONF_MIXER_TYPE);
if(param) { if(param) {
if(0); if(0);
#ifdef HAVE_ALSA #ifdef HAVE_ALSA
else if(strcmp(param->value, VOLUME_MIXER_ALSA)==0) { else if(strcmp(param->value, VOLUME_MIXER_ALSA)==0) {
@ -388,7 +388,7 @@ void initVolume() {
} }
param = getConfigParam(CONF_MIXER_DEVICE); param = getConfigParam(CONF_MIXER_DEVICE);
if(param) { if(param) {
volume_mixerDevice = param->value; volume_mixerDevice = param->value;
} }
@ -401,7 +401,7 @@ void openVolumeDevice() {
} }
} }
int getSoftwareVolume() { static int getSoftwareVolume() {
return volume_softwareSet; 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; int new = change;
if(rel) new+=volume_softwareSet; if(rel) new+=volume_softwareSet;
@ -455,7 +455,7 @@ int changeVolumeLevel(FILE * fp, int change, int rel) {
case VOLUME_MIXER_TYPE_SOFTWARE: case VOLUME_MIXER_TYPE_SOFTWARE:
return changeSoftwareVolume(fp,change,rel); return changeSoftwareVolume(fp,change,rel);
default: default:
return 0; return 0;
break; break;
} }
} }