[MPlayer-cvslog] r37163 - in trunk/gui/util: list.c list.h
ib
subversion at mplayerhq.hu
Thu Apr 24 14:09:37 CEST 2014
Author: ib
Date: Thu Apr 24 14:09:37 2014
New Revision: 37163
Log:
Add listDup().
(Currently unused, but we will need it soon.)
Modified:
trunk/gui/util/list.c
trunk/gui/util/list.h
Modified: trunk/gui/util/list.c
==============================================================================
--- trunk/gui/util/list.c Thu Apr 24 13:56:18 2014 (r37162)
+++ trunk/gui/util/list.c Thu Apr 24 14:09:37 2014 (r37163)
@@ -350,6 +350,36 @@ void listRepl(char ***list, const char *
}
/**
+ * @brief Duplicate a string list (by allocating new memory).
+ *
+ * @note The list must be NULL-terminated.
+ *
+ * @param list string list to be duplicated
+ *
+ * @return duplicated list
+ */
+char **listDup(const char *const *list)
+{
+ char **dup = NULL;
+
+ if (list) {
+ int i = 0;
+
+ while (list[i])
+ i++;
+
+ dup = calloc(i + 1, sizeof(char *));
+
+ if (dup) {
+ while (--i >= 0)
+ dup[i] = strdup(list[i]);
+ }
+ }
+
+ return dup;
+}
+
+/**
* @brief Append or insert a file to the playlist.
*
* @param what file to be added
Modified: trunk/gui/util/list.h
==============================================================================
--- trunk/gui/util/list.h Thu Apr 24 13:56:18 2014 (r37162)
+++ trunk/gui/util/list.h Thu Apr 24 14:09:37 2014 (r37163)
@@ -54,6 +54,7 @@ void *listMgr(int cmd, void *data);
/// @name String list operations
//@{
+char **listDup(const char *const *list);
void listFree(char ***list);
void listRepl(char ***list, const char *search, const char *replace);
void listSet(char ***list, const char *entry);
More information about the MPlayer-cvslog
mailing list