1 /* ncmpc (Ncurses MPD Client)
2 * (c) 2004-2017 The Music Player Daemon Project
3 * Project homepage: http://musicpd.org
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
20 #include "utils.h"
22 #include <stdlib.h>
23 #include <string.h>
25 GList *
26 string_list_free(GList *string_list)
27 {
28 g_list_free_full(string_list, g_free);
29 return NULL;
30 }
32 GList *
33 string_list_find(GList *string_list, const gchar *str)
34 {
35 GList *list = g_list_first(string_list);
37 while(list) {
38 if( strcmp(str, (gchar *) list->data) == 0 )
39 return list;
40 list = list->next;
41 }
42 return NULL;
43 }
45 GList *
46 string_list_remove(GList *string_list, const gchar *str)
47 {
48 GList *list = g_list_first(string_list);
50 while(list) {
51 if( strcmp(str, (gchar *) list->data) == 0 ) {
52 g_free(list->data);
53 list->data = NULL;
54 return g_list_delete_link(string_list, list);
55 }
56 list = list->next;
57 }
58 return list;
59 }