[MPlayer-dev-eng] [PATCH] remove some common code from gui/win32/interface.c

Stephen Sheldon sfsheldo at gmail.com
Sun Jul 10 16:24:53 CEST 2011


This patch removes the duplicated code from from gui/win32/interface.c
which is also in gui/util/list.c and gui/util/string.c.  It moves the
object files from the gtk section of the make file to the common section.

Index: Makefile
===================================================================
--- Makefile	(revision 33866)
+++ Makefile	(working copy)
@@ -517,7 +517,9 @@
 SRCS_MPLAYER-$(GL_WIN32)     += libvo/w32_common.c
 SRCS_MPLAYER-$(GL_X11)       += libvo/x11_common.c
 SRCS_MPLAYER-$(MATRIXVIEW)   += libvo/vo_matrixview.c libvo/matrixview.c
-SRCS_MPLAYER-$(GUI)          += gui/util/bitmap.c
+SRCS_MPLAYER-$(GUI)          += gui/util/bitmap.c \
+                                gui/util/list.c \
+                                gui/util/string.c
 SRCS_MPLAYER-$(GUI_GTK)      += gui/app.c \
                                 gui/cfg.c \
                                 gui/interface.c \
@@ -541,8 +543,6 @@
                                 gui/ui/sub.c \
                                 gui/ui/widgets.c \
                                 gui/util/cut.c \
-                                gui/util/list.c \
-                                gui/util/string.c \
                                 gui/wm/ws.c \
                                 gui/wm/wsxdnd.c \
 
Index: gui/win32/interface.c
===================================================================
--- gui/win32/interface.c	(revision 33866)
+++ gui/win32/interface.c	(working copy)
@@ -94,72 +94,6 @@
     return 0;
 }
 
-char *gstrdup(const char *str)
-{
-    if (!str) return NULL;
-    return strdup(str);
-}
-
-void setdup (char **old, const char *str)
-{
-  free(*old);
-  *old = gstrdup(str);
-}
-
-void setddup (char **old, const char *dir, const char *name)
-{
-  free(*old);
-  *old = malloc(strlen(dir) + strlen(name) + 2);
-  if (*old) sprintf(*old, "%s/%s", dir, name);
-}
-
-/**
- * \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.
- */
-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)))
-            {
-                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;
-}
-
 /* this function gets called by the gui to update mplayer */
 static void guiSetEvent(int event)
 {




More information about the MPlayer-dev-eng mailing list