make some functions a bit shorter.
[apps/madmutt.git] / lib / list.c
index 23dcf26..7ef6e6c 100644 (file)
 #include <string.h>
 
 #include <lib-lib/mem.h>
+#include <lib-lib/str.h>
 
 #include "list.h"
 
-#include "str.h"
 
 list2_t* list_new (void) {
   return p_new(list2_t, 1);
 }
 
 void list_del (list2_t** l, list_del_t* del) {
-  size_t i = 0;
+  ssize_t i = 0;
   if (!l || !*l)
     return;
   if (del)
@@ -88,16 +88,16 @@ list2_t *list_cpy(list2_t *l) {
     return ret;
 }
 
-list2_t* list_dup (list2_t* l, void* (*dup) (void*)) {
+list2_t* list_dup (list2_t* l, void* (*dup_f) (void*)) {
   list2_t* ret = NULL;
   int i = 0;
-  if (list_empty(l) || !*dup)
+  if (list_empty(l) || !*dup_f)
     return (NULL);
   ret = list_new ();
   ret->length = l->length;
   ret->data = p_new(void*, l->length);
   for (i = 0; i < l->length; i++)
-    ret->data[i] = dup (l->data[i]);
+    ret->data[i] = dup_f (l->data[i]);
   return (ret);
 }
 
@@ -118,9 +118,9 @@ list2_t* list_from_str (const char* str, const char* delim) {
   if (!str || !*str || !delim || !*delim)
     return (NULL);
 
-  tmp = str_dup (str);
+  tmp = m_strdup(str);
   for (p = strtok (tmp, delim); p; p = strtok (NULL, delim)) {
-    list_push_back (&ret, str_dup (p));
+    list_push_back (&ret, m_strdup(p));
   }
   p_delete(&tmp);
   return (ret);