drop the horrible list2_t for good.
[apps/madmutt.git] / lib / list.c
diff --git a/lib/list.c b/lib/list.c
deleted file mode 100644 (file)
index 0b852e0..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * written for mutt-ng by:
- * Rocco Rutte <pdmef@cs.tu-berlin.de>
- *
- * This file is part of mutt-ng, see http://www.muttng.org/.
- * It's licensed under the GNU General Public License,
- * please see the file GPL in the top level source directory.
- */
-
-#include <lib-lib/lib-lib.h>
-#include "list.h"
-
-list2_t* list_new (void) {
-  return p_new(list2_t, 1);
-}
-
-void list_del (list2_t** l, list_del_t* del) {
-  ssize_t i = 0;
-  if (!l || !*l)
-    return;
-  if (del)
-    for (i = 0; i < (*l)->length; i++)
-      del (&(*l)->data[i]);
-  p_delete(&(*l)->data);
-  p_delete(l);
-}
-
-void list_push_back (list2_t** l, void* p) {
-  if (!*l)
-    *l = list_new ();
-  p_realloc(&(*l)->data, ++(*l)->length);
-  (*l)->data[(*l)->length-1] = p;
-}
-
-void list_push_front (list2_t** l, void* p) {
-  if (!*l)
-    *l = list_new ();
-  p_realloc(&(*l)->data, ++(*l)->length);
-  if ((*l)->length > 1)
-    memmove (&(*l)->data[1], &(*l)->data[0], ((*l)->length-1)*sizeof(void*));
-  (*l)->data[0] = p;
-}
-
-void* list_pop_back (list2_t* l) {
-  void* p = NULL;
-  if (list_empty(l))
-    return (NULL);
-  p = l->data[l->length-1];
-  p_realloc(&l->data, --(l->length));
-  return (p);
-}
-
-void* list_pop_front (list2_t* l) {
-  void* p = NULL;
-  if (list_empty(l))
-    return (NULL);
-  p = l->data[0];
-  memmove (&l->data[0], &l->data[1], (--(l->length))*sizeof(void*));
-  p_realloc(&l->data, l->length);
-  return (p);
-}
-
-void* list_pop_idx (list2_t* l, int c) {
-  void* p = NULL;
-  if (list_empty(l) || c < 0 || c >= l->length)
-    return (NULL);
-  if (c == l->length-1)
-    return (list_pop_back (l));
-  p = l->data[c];
-  memmove (&l->data[c], &l->data[c+1], (l->length-c)*sizeof(void*));
-  p_realloc(&l->data, --(l->length));
-  return (p);
-}
-
-list2_t *list_cpy(list2_t *l) {
-    list2_t* ret = NULL;
-    if (list_empty(l))
-        return NULL;
-    ret = list_new();
-    ret->length = l->length;
-    ret->data = p_dup(l->data, l->length);
-    return ret;
-}
-
-list2_t* list_dup (list2_t* l, void* (*dup_f) (void*)) {
-  list2_t* ret = NULL;
-  int i = 0;
-  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_f (l->data[i]);
-  return (ret);
-}
-
-int list_lookup (list2_t* l, int (*cmp) (const void*, const void*), const void* p) {
-  int i = 0;
-  if (list_empty(l) || !*cmp)
-    return (-1);
-  for (i = 0; i < l->length; i++)
-    if (cmp (l->data[i], p) == 0)
-      return (i);
-  return (-1);
-}
-
-list2_t* list_from_str (const char* str, const char* delim) {
-  list2_t* ret = NULL;
-  char* tmp = NULL, *p = NULL;
-
-  if (!str || !*str || !delim || !*delim)
-    return (NULL);
-
-  tmp = m_strdup(str);
-  for (p = strtok (tmp, delim); p; p = strtok (NULL, delim)) {
-    list_push_back (&ret, m_strdup(p));
-  }
-  p_delete(&tmp);
-  return (ret);
-}
-