diff options
author | Max Kellermann <max@duempel.org> | 2009-01-23 16:22:43 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2009-01-23 16:22:43 +0100 |
commit | 4c77a4c4946b6ee029b1a050ed10401a53c91aee (patch) | |
tree | fc09aaa1afeca0acd8ee9b86b0135726c8d15fe3 /src/playlist.c | |
parent | 3a86a6ca169e987490f94883b7d5be1a9a1f1b3d (diff) | |
download | mpd-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.c | 26 |
1 files changed, 11 insertions, 15 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); |