aboutsummaryrefslogtreecommitdiffstats
path: root/src/list.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-02-05 10:17:33 +0000
committerEric Wong <normalperson@yhbt.net>2008-02-05 10:17:33 +0000
commit6fbdc721d972d8c1f823acd5473a3dce8836d5fa (patch)
treee72131541f4e887d5dedd6c75ffce455cbf6b97c /src/list.c
parent22efbd5eca4705426af5cee17a65a3e76c33bec6 (diff)
downloadmpd-6fbdc721d972d8c1f823acd5473a3dce8836d5fa.tar.gz
mpd-6fbdc721d972d8c1f823acd5473a3dce8836d5fa.tar.xz
mpd-6fbdc721d972d8c1f823acd5473a3dce8836d5fa.zip
fix -Wconst warnings
[ew: cleaned up the dirty union hack a bit] Signed-off-by: Eric Wong <normalperson@yhbt.net> git-svn-id: https://svn.musicpd.org/mpd/trunk@7180 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r--src/list.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/list.c b/src/list.c
index 6a54d8a5f..65ad4ec98 100644
--- a/src/list.c
+++ b/src/list.c
@@ -63,7 +63,7 @@ List *makeList(ListFreeDataFunc * freeDataFunc, int strdupKeys)
}
ListNode *insertInListBeforeNode(List * list, ListNode * beforeNode, int pos,
- char *key, void *data)
+ const char *key, void *data)
{
ListNode *node;
@@ -126,7 +126,7 @@ ListNode *insertInListBeforeNode(List * list, ListNode * beforeNode, int pos,
return node;
}
-ListNode *insertInList(List * list, char *key, void *data)
+ListNode *insertInList(List * list, const char *key, void *data)
{
ListNode *node;
@@ -201,7 +201,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 */
-int findNodeInList(List * list, char *key, ListNode ** node, int *pos)
+int findNodeInList(List * list, const char *key, ListNode ** node, int *pos)
{
long high;
long low;
@@ -268,7 +268,7 @@ int findNodeInList(List * list, char *key, ListNode ** node, int *pos)
return 0;
}
-int findInList(List * list, char *key, void **data)
+int findInList(List * list, const char *key, void **data)
{
ListNode *node;
int pos;
@@ -282,7 +282,7 @@ int findInList(List * list, char *key, void **data)
return 0;
}
-int deleteFromList(List * list, char *key)
+int deleteFromList(List * list, const char *key)
{
ListNode *tmpNode;
@@ -302,6 +302,11 @@ int deleteFromList(List * list, char *key)
return 1;
}
+static void free_const_string(const char *p)
+{
+ free((char *)p);
+}
+
void deleteNodeFromList(List * list, ListNode * node)
{
assert(list != NULL);
@@ -322,7 +327,7 @@ void deleteNodeFromList(List * list, ListNode * node)
}
if (list->strdupKeys)
- free(node->key);
+ free_const_string(node->key);
free(node);
list->numberOfNodes--;
@@ -349,7 +354,7 @@ void freeList(void *list)
while (tmpNode != NULL) {
tmpNode2 = tmpNode->nextNode;
if (((List *) list)->strdupKeys)
- free(tmpNode->key);
+ free_const_string(tmpNode->key);
if (((List *) list)->freeDataFunc) {
((List *) list)->freeDataFunc(tmpNode->data);
}
@@ -362,7 +367,7 @@ void freeList(void *list)
static void swapNodes(ListNode * nodeA, ListNode * nodeB)
{
- char *key;
+ const char *key;
void *data;
assert(nodeA != NULL);
@@ -408,7 +413,7 @@ static void quickSort(ListNode ** nodesArray, long start, long end)
ListNode *node;
long pivot;
ListNode *pivotNode;
- char *pivotKey;
+ const char *pivotKey;
List *startList = makeList(free, 0);
List *endList = makeList(free, 0);