Mercurial > mplayer.hg
diff gui/interface.c @ 33741:962dc701989d
Create new file list.c for list related functions.
Move gaddlist() and greplace() from interface.c to list.c.
| author | ib |
|---|---|
| date | Thu, 07 Jul 2011 10:37:58 +0000 |
| parents | 2c02269701bd |
| children | e1539e14d60f |
line wrap: on
line diff
--- a/gui/interface.c Thu Jul 07 10:16:22 2011 +0000 +++ b/gui/interface.c Thu Jul 07 10:37:58 2011 +0000 @@ -24,6 +24,7 @@ #include "skin/skin.h" #include "ui/gmplayer.h" #include "ui/widgets.h" +#include "util/list.h" #include "util/mem.h" #include "util/string.h" #include "wm/ws.h" @@ -77,51 +78,6 @@ static int initialized; -/** - * \brief This actually creates a new list containing only one element... - */ -void gaddlist(char ***list, const char *entry) -{ - int i; - - if (*list) { - for (i = 0; (*list)[i]; i++) - free((*list)[i]); - - free(*list); - } - - *list = malloc(2 * sizeof(char **)); - (*list)[0] = gstrdup(entry); - (*list)[1] = NULL; -} - -/** - * \brief This replaces a string starting with search by replace. - * If not found, replace is appended. - */ -static void greplace(char ***list, const char *search, const char *replace) -{ - int i = 0; - int len = (search ? strlen(search) : 0); - - if (*list) { - for (i = 0; (*list)[i]; i++) { - if (search && (strncmp((*list)[i], search, len) == 0)) { - free((*list)[i]); - (*list)[i] = gstrdup(replace); - return; - } - } - - *list = realloc(*list, (i + 2) * sizeof(char *)); - } else - *list = malloc(2 * sizeof(char *)); - - (*list)[i] = gstrdup(replace); - (*list)[i + 1] = NULL; -} - void guiInit(void) { int i;
