[MPlayer-cvslog] r37162 - in trunk/gui/util: list.c list.h

ib subversion at mplayerhq.hu
Thu Apr 24 13:56:18 CEST 2014


Author: ib
Date: Thu Apr 24 13:56:18 2014
New Revision: 37162

Log:
Add listFree().

Use it in listSet().

(This is the only purpose of use at the moment, but we will need
listFree() later which is the reason behind setting the pointer
to NULL after freeing.)

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:31:31 2014	(r37161)
+++ trunk/gui/util/list.c	Thu Apr 24 13:56:18 2014	(r37162)
@@ -26,6 +26,7 @@
 #include <string.h>
 
 #include "list.h"
+#include "mem.h"
 #include "string.h"
 #include "gui/app/gui.h"
 
@@ -269,14 +270,11 @@ void *listMgr(int cmd, void *data)
 }
 
 /**
- * @brief Set string list to @a entry.
+ * @brief Free a string list.
  *
  * @param list pointer to the string list
- * @param entry the new (and only) element of the list
- *
- * @note Actually, a new list will be created and the old list will be freed.
  */
-void listSet(char ***list, const char *entry)
+void listFree(char ***list)
 {
     if (*list) {
         char **l = *list;
@@ -286,8 +284,21 @@ void listSet(char ***list, const char *e
             l++;
         }
 
-        free(*list);
+        nfree(*list);
     }
+}
+
+/**
+ * @brief Set string list to @a entry.
+ *
+ * @param list pointer to the string list
+ * @param entry the new (and only) element of the list
+ *
+ * @note Actually, a new list will be created and the old list will be freed.
+ */
+void listSet(char ***list, const char *entry)
+{
+    listFree(list);
 
     *list = malloc(2 * sizeof(char *));
 

Modified: trunk/gui/util/list.h
==============================================================================
--- trunk/gui/util/list.h	Thu Apr 24 13:31:31 2014	(r37161)
+++ trunk/gui/util/list.h	Thu Apr 24 13:56:18 2014	(r37162)
@@ -54,6 +54,7 @@ void *listMgr(int cmd, void *data);
 
 /// @name String list operations
 //@{
+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