aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-01-23 16:22:43 +0100
committerMax Kellermann <max@duempel.org>2009-01-23 16:22:43 +0100
commit4c77a4c4946b6ee029b1a050ed10401a53c91aee (patch)
treefc09aaa1afeca0acd8ee9b86b0135726c8d15fe3 /src
parent3a86a6ca169e987490f94883b7d5be1a9a1f1b3d (diff)
downloadmpd-4c77a4c4946b6ee029b1a050ed10401a53c91aee.tar.gz
mpd-4c77a4c4946b6ee029b1a050ed10401a53c91aee.tar.xz
mpd-4c77a4c4946b6ee029b1a050ed10401a53c91aee.zip
playlist: pass const pointers to search functions
The LocateTagItem objects are not modified.
Diffstat (limited to '')
-rw-r--r--src/playlist.c26
-rw-r--r--src/playlist.h10
2 files changed, 17 insertions, 19 deletions
diff --git a/src/playlist.c b/src/playlist.c
index 0c9dfa44a..0a3f3271e 100644
--- a/src/playlist.c
+++ b/src/playlist.c
@@ -1297,16 +1297,16 @@ enum playlist_result loadPlaylist(const char *utf8file)
return PLAYLIST_RESULT_SUCCESS;
}
-void searchForSongsInPlaylist(struct client *client,
- unsigned numItems, LocateTagItem * items)
+void
+searchForSongsInPlaylist(struct client *client,
+ unsigned numItems, const LocateTagItem *items)
{
unsigned i;
- char **originalNeedles = g_malloc(numItems * sizeof(char *));
+ LocateTagItem *new_items =
+ g_memdup(items, sizeof(LocateTagItem) * numItems);
- for (i = 0; i < numItems; i++) {
- originalNeedles[i] = items[i].needle;
- items[i].needle = g_utf8_casefold(originalNeedles[i], -1);
- }
+ for (i = 0; i < numItems; i++)
+ new_items[i].needle = g_utf8_casefold(new_items[i].needle, -1);
for (i = 0; i < queue_length(&playlist.queue); i++) {
const struct song *song = queue_get(&playlist.queue, i);
@@ -1315,16 +1315,12 @@ void searchForSongsInPlaylist(struct client *client,
printPlaylistSongInfo(client, i);
}
- for (i = 0; i < numItems; i++) {
- g_free(items[i].needle);
- items[i].needle = originalNeedles[i];
- }
-
- free(originalNeedles);
+ freeLocateTagItemArray(numItems, new_items);
}
-void findSongsInPlaylist(struct client *client,
- unsigned numItems, LocateTagItem * items)
+void
+findSongsInPlaylist(struct client *client,
+ unsigned numItems, const LocateTagItem *items)
{
for (unsigned i = 0; i < queue_length(&playlist.queue); i++) {
const struct song *song = queue_get(&playlist.queue, i);
diff --git a/src/playlist.h b/src/playlist.h
index 14813ea17..c1c651a77 100644
--- a/src/playlist.h
+++ b/src/playlist.h
@@ -176,11 +176,13 @@ int playlistChangesPosId(struct client *client, uint32_t version);
int PlaylistInfo(struct client *client, const char *utf8file, int detail);
-void searchForSongsInPlaylist(struct client *client,
- unsigned numItems, LocateTagItem * items);
+void
+searchForSongsInPlaylist(struct client *client,
+ unsigned numItems, const LocateTagItem *items);
-void findSongsInPlaylist(struct client *client,
- unsigned numItems, LocateTagItem * items);
+void
+findSongsInPlaylist(struct client *client,
+ unsigned numItems, const LocateTagItem *items);
int is_valid_playlist_name(const char *utf8path);