gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r34562 - in gnunet/src: include util


From: gnunet
Subject: [GNUnet-SVN] r34562 - in gnunet/src: include util
Date: Sun, 14 Dec 2014 23:15:06 +0100

Author: grothoff
Date: 2014-12-14 23:15:06 +0100 (Sun, 14 Dec 2014)
New Revision: 34562

Removed:
   gnunet/src/util/container_slist.c
   gnunet/src/util/test_container_slist.c
Modified:
   gnunet/src/include/gnunet_container_lib.h
   gnunet/src/util/Makefile.am
Log:
fix #3570: finally remove SList API

Modified: gnunet/src/include/gnunet_container_lib.h
===================================================================
--- gnunet/src/include/gnunet_container_lib.h   2014-12-14 22:14:11 UTC (rev 
34561)
+++ gnunet/src/include/gnunet_container_lib.h   2014-12-14 22:15:06 UTC (rev 
34562)
@@ -1818,251 +1818,6 @@
                                    GNUNET_CONTAINER_HeapCostType new_cost);
 
 
-/* ******************** Singly linked list *************** */
-
-/**
- * Possible ways for how data stored in the linked list
- * might be allocated.
- * @deprecated use DLL macros
- */
-enum GNUNET_CONTAINER_SListDisposition
-{
-  /**
-   * Single-linked list must copy the buffer.
-   * @deprecated use DLL macros
-   */
-  GNUNET_CONTAINER_SLIST_DISPOSITION_TRANSIENT = 0,
-
-  /**
-   * Data is static, no need to copy or free.
-   * @deprecated use DLL macros
-   */
-  GNUNET_CONTAINER_SLIST_DISPOSITION_STATIC = 2,
-
-  /**
-   * Data is dynamic, do not copy but free when done.
-   * @deprecated use DLL macros
-   */
-  GNUNET_CONTAINER_SLIST_DISPOSITION_DYNAMIC = 4
-};
-
-struct GNUNET_CONTAINER_SList_Elem;
-
-
-/**
- * Handle to a singly linked list
- * @deprecated use DLL macros
- */
-struct GNUNET_CONTAINER_SList;
-
-/**
- * Handle to a singly linked list iterator
- * @deprecated use DLL macros
- */
-struct GNUNET_CONTAINER_SList_Iterator
-{
-  /**
-   * Linked list that we are iterating over.
-   */
-  struct GNUNET_CONTAINER_SList *list;
-
-  /**
-   * Last element accessed.
-   */
-  struct GNUNET_CONTAINER_SList_Elem *last;
-
-  /**
-   * Current list element.
-   */
-  struct GNUNET_CONTAINER_SList_Elem *elem;
-};
-
-
-
-/**
- * Add a new element to the list
- * @param l list
- * @param disp memory disposition
- * @param buf payload buffer
- * @param len length of the buffer
- * @deprecated use DLL macros
- */
-void
-GNUNET_CONTAINER_slist_add (struct GNUNET_CONTAINER_SList *l,
-                            enum GNUNET_CONTAINER_SListDisposition disp,
-                            const void *buf, size_t len);
-
-
-/**
- * Add a new element to the end of the list
- * @param l list
- * @param disp memory disposition
- * @param buf payload buffer
- * @param len length of the buffer
- * @deprecated use DLL macros
- */
-void
-GNUNET_CONTAINER_slist_add_end (struct GNUNET_CONTAINER_SList *l,
-                                enum GNUNET_CONTAINER_SListDisposition disp,
-                                const void *buf, size_t len);
-
-
-/**
- * Append a singly linked list to another
- * @param dst list to append to
- * @param src source
- * @deprecated use DLL macros
- */
-void
-GNUNET_CONTAINER_slist_append (struct GNUNET_CONTAINER_SList *dst,
-                               struct GNUNET_CONTAINER_SList *src);
-
-
-/**
- * Create a new singly linked list
- * @return the new list
- * @deprecated use DLL macros
- */
-struct GNUNET_CONTAINER_SList *
-GNUNET_CONTAINER_slist_create (void);
-
-
-/**
- * Destroy a singly linked list
- * @param l the list to be destroyed
- * @deprecated use DLL macros
- */
-void
-GNUNET_CONTAINER_slist_destroy (struct GNUNET_CONTAINER_SList *l);
-
-
-/**
- * Return the beginning of a list
- *
- * @param l list
- * @return iterator pointing to the beginning (by value! Either allocate the
- *   structure on the stack, or use GNUNET_malloc() yourself! All other
- *   functions do take pointer to this struct though)
- * @deprecated use DLL macros
- */
-struct GNUNET_CONTAINER_SList_Iterator
-GNUNET_CONTAINER_slist_begin (struct GNUNET_CONTAINER_SList *l);
-
-
-/**
- * Clear a list
- *
- * @param l list
- * @deprecated use DLL macros
- */
-void
-GNUNET_CONTAINER_slist_clear (struct GNUNET_CONTAINER_SList *l);
-
-
-/**
- * Check if a list contains a certain element
- * @param l list
- * @param buf payload buffer to find
- * @param len length of the payload (number of bytes in buf)
- * @return GNUNET_YES if found, GNUNET_NO otherwise
- * @deprecated use DLL macros
- */
-int
-GNUNET_CONTAINER_slist_contains (const struct GNUNET_CONTAINER_SList *l,
-                                 const void *buf, size_t len);
-
-/**
- * Check if a list contains a certain element using 'compare' function
- *
- * @param l list
- * @param buf payload buffer to find
- * @param len length of the payload (number of bytes in buf)
- * @param compare comparison function
- *
- * @return NULL if the 'buf' could not be found, pointer to the
- *         list element, if found
- * @deprecated use DLL macros
- */
-void *
-GNUNET_CONTAINER_slist_contains2 (const struct GNUNET_CONTAINER_SList *l,
-                                  const void *buf, size_t len,
-                                  int (*compare)(const void *, const size_t, 
const void *, const size_t));
-/**
- * Count the elements of a list
- * @param l list
- * @return number of elements in the list
- * @deprecated use DLL macros
- */
-int
-GNUNET_CONTAINER_slist_count (const struct GNUNET_CONTAINER_SList *l);
-
-
-/**
- * Remove an element from the list
- * @param i iterator that points to the element to be removed
- * @deprecated use DLL macros
- */
-void
-GNUNET_CONTAINER_slist_erase (struct GNUNET_CONTAINER_SList_Iterator *i);
-
-
-/**
- * Insert an element into a list at a specific position
- * @param before where to insert the new element
- * @param disp memory disposition
- * @param buf payload buffer
- * @param len length of the payload
- * @deprecated use DLL macros
- */
-void
-GNUNET_CONTAINER_slist_insert (struct GNUNET_CONTAINER_SList_Iterator *before,
-                               enum GNUNET_CONTAINER_SListDisposition disp,
-                               const void *buf, size_t len);
-
-
-/**
- * Advance an iterator to the next element
- * @param i iterator
- * @return GNUNET_YES on success, GNUNET_NO if the end has been reached
- * @deprecated use DLL macros
- */
-int
-GNUNET_CONTAINER_slist_next (struct GNUNET_CONTAINER_SList_Iterator *i);
-
-
-/**
- * Check if an iterator points beyond the end of a list
- * @param i iterator
- * @return GNUNET_YES if the end has been reached, GNUNET_NO if the iterator
- *         points to a valid element
- * @deprecated use DLL macros
- */
-int
-GNUNET_CONTAINER_slist_end (struct GNUNET_CONTAINER_SList_Iterator *i);
-
-
-/**
- * Retrieve the element at a specific position in a list
- *
- * @param i iterator
- * @param len set to the payload length
- * @return payload
- * @deprecated use DLL macros
- */
-void *
-GNUNET_CONTAINER_slist_get (const struct GNUNET_CONTAINER_SList_Iterator *i,
-                            size_t *len);
-
-
-/**
- * Release an iterator
- * @param i iterator
- * @deprecated use DLL macros
- */
-void
-GNUNET_CONTAINER_slist_iter_destroy (struct GNUNET_CONTAINER_SList_Iterator 
*i);
-
-
 #if 0                           /* keep Emacsens' auto-indent happy */
 {
 #endif

Modified: gnunet/src/util/Makefile.am
===================================================================
--- gnunet/src/util/Makefile.am 2014-12-14 22:14:11 UTC (rev 34561)
+++ gnunet/src/util/Makefile.am 2014-12-14 22:15:06 UTC (rev 34562)
@@ -79,7 +79,6 @@
   container_multihashmap.c \
   container_multipeermap.c \
   container_multihashmap32.c \
-  container_slist.c \
   crypto_symmetric.c \
   crypto_crc.c \
   crypto_ecc.c \
@@ -221,7 +220,6 @@
  test_container_multihashmap32 \
  test_container_multipeermap \
  test_container_heap \
- test_container_slist \
  test_crypto_symmetric \
  test_crypto_crc \
  test_crypto_ecdsa \

Deleted: gnunet/src/util/container_slist.c
===================================================================
--- gnunet/src/util/container_slist.c   2014-12-14 22:14:11 UTC (rev 34561)
+++ gnunet/src/util/container_slist.c   2014-12-14 22:15:06 UTC (rev 34562)
@@ -1,414 +0,0 @@
-/*
-     This file is part of GNUnet.
-     (C) 2009 Christian Grothoff (and other contributing authors)
-
-     GNUnet is free software; you can redistribute it and/or modify
-     it under the terms of the GNU General Public License as published
-     by the Free Software Foundation; either version 3, or (at your
-     option) any later version.
-
-     GNUnet is distributed in the hope that it will be useful, but
-     WITHOUT ANY WARRANTY; without even the implied warranty of
-     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-     General Public License for more details.
-
-     You should have received a copy of the GNU General Public License
-     along with GNUnet; see the file COPYING.  If not, write to the
-     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-     Boston, MA 02111-1307, USA.
-*/
-
-/**
- * @file util/container_slist.c
- * @brief Implementation of a singly-linked list
- * @author Nils Durner
- */
-
-#include "platform.h"
-#include "gnunet_container_lib.h"
-
-#define LOG(kind,...) GNUNET_log_from (kind, "util", __VA_ARGS__)
-
-/**
- * Element in our linked list.
- */
-struct GNUNET_CONTAINER_SList_Elem
-{
-  /**
-   * This is a linked list.
-   */
-  struct GNUNET_CONTAINER_SList_Elem *next;
-
-  /**
-   * Application data stored at this element.
-   */
-  void *elem;
-
-  /**
-   * Number of bytes stored in elem.
-   */
-  size_t len;
-
-  /**
-   * Disposition of the element.
-   */
-  enum GNUNET_CONTAINER_SListDisposition disp;
-};
-
-
-/**
- * Handle to a singly linked list
- */
-struct GNUNET_CONTAINER_SList
-{
-  /**
-   * Head of the linked list.
-   */
-  struct GNUNET_CONTAINER_SList_Elem *head;
-
-  /**
-   * Tail of the linked list.
-   */
-  struct GNUNET_CONTAINER_SList_Elem *tail;
-
-  /**
-   * Number of elements in the list.
-   */
-  unsigned int length;
-};
-
-
-
-/**
- * Create a new element that is to be inserted into the list
- * @internal
- * @param disp memory disposition
- * @param buf payload buffer
- * @param len length of the buffer
- * @return a new element
- */
-static struct GNUNET_CONTAINER_SList_Elem *
-create_elem (enum GNUNET_CONTAINER_SListDisposition disp, const void *buf,
-             size_t len)
-{
-  struct GNUNET_CONTAINER_SList_Elem *e;
-
-  if (disp == GNUNET_CONTAINER_SLIST_DISPOSITION_TRANSIENT)
-  {
-    e = GNUNET_malloc (sizeof (struct GNUNET_CONTAINER_SList_Elem) + len);
-    memcpy (&e[1], buf, len);
-    e->elem = (void *) &e[1];
-  }
-  else
-  {
-    e = GNUNET_new (struct GNUNET_CONTAINER_SList_Elem);
-    e->elem = (void *) buf;
-  }
-  e->disp = disp;
-  e->len = len;
-  return e;
-}
-
-
-/**
- * Add a new element to the list
- * @param l list
- * @param disp memory disposition
- * @param buf payload buffer
- * @param len length of the buffer
- */
-void
-GNUNET_CONTAINER_slist_add (struct GNUNET_CONTAINER_SList *l,
-                            enum GNUNET_CONTAINER_SListDisposition disp,
-                            const void *buf, size_t len)
-{
-  struct GNUNET_CONTAINER_SList_Elem *e;
-
-  e = create_elem (disp, buf, len);
-  e->next = l->head;
-  l->head = e;
-  if (l->tail == NULL)
-    l->tail = e;
-  l->length++;
-}
-
-/**
- * Add a new element to the end of the list
- * @param l list
- * @param disp memory disposition
- * @param buf payload buffer
- * @param len length of the buffer
- */
-void
-GNUNET_CONTAINER_slist_add_end (struct GNUNET_CONTAINER_SList *l,
-                                enum GNUNET_CONTAINER_SListDisposition disp,
-                                const void *buf, size_t len)
-{
-  struct GNUNET_CONTAINER_SList_Elem *e;
-
-  e = create_elem (disp, buf, len);
-  if (l->tail != NULL)
-    l->tail->next = e;
-  if (l->head == NULL)
-    l->head = e;
-  l->tail = e;
-  l->length++;
-}
-
-
-/**
- * Append a singly linked list to another
- * @param dst list to append to
- * @param src source
- */
-void
-GNUNET_CONTAINER_slist_append (struct GNUNET_CONTAINER_SList *dst,
-                               struct GNUNET_CONTAINER_SList *src)
-{
-  struct GNUNET_CONTAINER_SList_Iterator i;
-
-  for (i = GNUNET_CONTAINER_slist_begin (src);
-       GNUNET_CONTAINER_slist_end (&i) != GNUNET_YES;
-       GNUNET_CONTAINER_slist_next (&i))
-
-  {
-    GNUNET_CONTAINER_slist_add (dst,
-                                (i.elem->disp ==
-                                 GNUNET_CONTAINER_SLIST_DISPOSITION_STATIC) ?
-                                GNUNET_CONTAINER_SLIST_DISPOSITION_STATIC :
-                                GNUNET_CONTAINER_SLIST_DISPOSITION_TRANSIENT,
-                                i.elem->elem, i.elem->len);
-  }
-  GNUNET_CONTAINER_slist_iter_destroy (&i);
-}
-
-
-/**
- * Create a new singly linked list
- * @return the new list
- */
-struct GNUNET_CONTAINER_SList *
-GNUNET_CONTAINER_slist_create ()
-{
-  return GNUNET_new (struct GNUNET_CONTAINER_SList);
-}
-
-
-/**
- * Destroy a singly linked list
- * @param l the list to be destroyed
- */
-void
-GNUNET_CONTAINER_slist_destroy (struct GNUNET_CONTAINER_SList *l)
-{
-  GNUNET_CONTAINER_slist_clear (l);
-  GNUNET_free (l);
-}
-
-
-/**
- * Return the beginning of a list
- * @param l list
- * @return iterator pointing to the beginning
- */
-struct GNUNET_CONTAINER_SList_Iterator
-GNUNET_CONTAINER_slist_begin (struct GNUNET_CONTAINER_SList *l)
-{
-  struct GNUNET_CONTAINER_SList_Iterator ret;
-
-  memset (&ret, 0, sizeof (ret));
-  ret.elem = l->head;
-  ret.list = l;
-  return ret;
-}
-
-
-/**
- * Clear a list
- * @param l list
- */
-void
-GNUNET_CONTAINER_slist_clear (struct GNUNET_CONTAINER_SList *l)
-{
-  struct GNUNET_CONTAINER_SList_Elem *e;
-  struct GNUNET_CONTAINER_SList_Elem *n;
-
-  e = l->head;
-  while (e != NULL)
-  {
-    n = e->next;
-    if (e->disp == GNUNET_CONTAINER_SLIST_DISPOSITION_DYNAMIC)
-      GNUNET_free (e->elem);
-    GNUNET_free (e);
-    e = n;
-  }
-  l->head = NULL;
-  l->tail = NULL;
-  l->length = 0;
-}
-
-
-/**
- * Check if a list contains a certain element
- * @param l list
- * @param buf payload buffer to find
- * @param len length of the payload (number of bytes in buf)
- *
- * @return GNUNET_YES if found, GNUNET_NO otherwise
- */
-int
-GNUNET_CONTAINER_slist_contains (const struct GNUNET_CONTAINER_SList *l,
-                                 const void *buf, size_t len)
-{
-  struct GNUNET_CONTAINER_SList_Elem *e;
-
-  for (e = l->head; e != NULL; e = e->next)
-    if ((e->len == len) && (memcmp (buf, e->elem, len) == 0))
-      return GNUNET_YES;
-  return GNUNET_NO;
-}
-
-typedef int (*Comparator)(const void *,  size_t, const void *,  size_t);
-
-/**
- * Check if a list contains a certain element
- *
- * @param l list
- * @param buf payload buffer to find
- * @param len length of the payload (number of bytes in buf)
- * @param compare comparison function, should return 0 if compared elements 
match
- *
- * @return NULL if the 'buf' could not be found, pointer to the
- *         list element, if found
- */
-void *
-GNUNET_CONTAINER_slist_contains2 (const struct GNUNET_CONTAINER_SList *l,
-                                  const void *buf, size_t len,
-                                  Comparator compare)
-{
-  struct GNUNET_CONTAINER_SList_Elem *e;
-
-  for (e = l->head; e != NULL; e = e->next)
-    if ((e->len == len) && (*compare)(buf, len, e->elem, e->len) == 0)
-      return e->elem;
-  return NULL;
-}
-
-
-/**
- * Count the elements of a list
- * @param l list
- * @return number of elements in the list
- */
-int
-GNUNET_CONTAINER_slist_count (const struct GNUNET_CONTAINER_SList *l)
-{
-  return l->length;
-}
-
-
-/**
- * Remove an element from the list
- *
- * @param i iterator that points to the element to be removed
- */
-void
-GNUNET_CONTAINER_slist_erase (struct GNUNET_CONTAINER_SList_Iterator *i)
-{
-  struct GNUNET_CONTAINER_SList_Elem *next;
-
-  next = i->elem->next;
-  if (i->last != NULL)
-    i->last->next = next;
-  else
-    i->list->head = next;
-  if (next == NULL)
-    i->list->tail = i->last;
-  if (i->elem->disp == GNUNET_CONTAINER_SLIST_DISPOSITION_DYNAMIC)
-    GNUNET_free (i->elem->elem);
-  GNUNET_free (i->elem);
-  i->list->length--;
-  i->elem = next;
-}
-
-
-/**
- * Insert an element into a list at a specific position
- * @param before where to insert the new element
- * @param disp memory disposition
- * @param buf payload buffer
- * @param len length of the payload
- */
-void
-GNUNET_CONTAINER_slist_insert (struct GNUNET_CONTAINER_SList_Iterator *before,
-                               enum GNUNET_CONTAINER_SListDisposition disp,
-                               const void *buf, size_t len)
-{
-  struct GNUNET_CONTAINER_SList_Elem *e;
-
-  e = create_elem (disp, buf, len);
-  e->next = before->elem;
-  if (before->last != NULL)
-    before->last->next = e;
-  else
-    before->list->head = e;
-  if (e->next == NULL)
-    before->list->tail = e;
-  before->list->length++;
-}
-
-
-/**
- * Advance an iterator to the next element
- * @param i iterator
- * @return GNUNET_YES on success, GNUNET_NO if the end has been reached
- */
-int
-GNUNET_CONTAINER_slist_next (struct GNUNET_CONTAINER_SList_Iterator *i)
-{
-  i->last = i->elem;
-  i->elem = i->elem->next;
-
-  return (i->elem != NULL) ? GNUNET_YES : GNUNET_NO;
-}
-
-
-/**
- * Check if an iterator points beyond the end of a list
- *
- * @param i iterator
- * @return GNUNET_YES if the end has been reached, GNUNET_NO if the iterator
- *         points to a valid element
- */
-int
-GNUNET_CONTAINER_slist_end (struct GNUNET_CONTAINER_SList_Iterator *i)
-{
-  return (i->elem == NULL) ? GNUNET_YES : GNUNET_NO;
-}
-
-
-/**
- * Retrieve the element at a specific position in a list
- * @param i iterator
- * @param len payload length
- * @return payload
- */
-void *
-GNUNET_CONTAINER_slist_get (const struct GNUNET_CONTAINER_SList_Iterator *i,
-                            size_t * len)
-{
-  if (len)
-    *len = i->elem->len;
-  return i->elem->elem;
-}
-
-/**
- * Release an iterator
- * @param i iterator
- */
-void
-GNUNET_CONTAINER_slist_iter_destroy (struct GNUNET_CONTAINER_SList_Iterator *i)
-{
-}
-
-/* end of container_slist.c */

Deleted: gnunet/src/util/test_container_slist.c
===================================================================
--- gnunet/src/util/test_container_slist.c      2014-12-14 22:14:11 UTC (rev 
34561)
+++ gnunet/src/util/test_container_slist.c      2014-12-14 22:15:06 UTC (rev 
34562)
@@ -1,159 +0,0 @@
-/*
-     This file is part of GNUnet.
-     (C) 2009 Christian Grothoff (and other contributing authors)
-
-     GNUnet is free software; you can redistribute it and/or modify
-     it under the terms of the GNU General Public License as published
-     by the Free Software Foundation; either version 3, or (at your
-     option) any later version.
-
-     GNUnet is distributed in the hope that it will be useful, but
-     WITHOUT ANY WARRANTY; without even the implied warranty of
-     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-     General Public License for more details.
-
-     You should have received a copy of the GNU General Public License
-     along with GNUnet; see the file COPYING.  If not, write to the
-     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-     Boston, MA 02111-1307, USA.
-*/
-
-/**
- * @file util/test_container_slist.c
- * @brief Testcases for singly linked lists
- * @author Nils Durner
- */
-
-#include "platform.h"
-#include "gnunet_util_lib.h"
-
-int
-main (int argc, char *argv[])
-{
-  struct GNUNET_CONTAINER_SList *l;
-  struct GNUNET_CONTAINER_SList_Iterator it;
-  unsigned int i;
-  int *ip;
-  unsigned int j;
-  size_t s;
-  const void *p;
-
-  GNUNET_log_setup ("test-container-slist", "WARNING", NULL);
-
-  l = GNUNET_CONTAINER_slist_create ();
-  GNUNET_assert (l != NULL);
-  GNUNET_assert (GNUNET_CONTAINER_slist_count (l) == 0);
-
-  for (i = 0; i < 100; i++)
-    GNUNET_CONTAINER_slist_add (l, 
GNUNET_CONTAINER_SLIST_DISPOSITION_TRANSIENT,
-                                &i, sizeof (i));
-  GNUNET_assert (GNUNET_CONTAINER_slist_count (l) == 100);
-
-  for (it = GNUNET_CONTAINER_slist_begin (l), i = 99;
-       GNUNET_CONTAINER_slist_end (&it) != GNUNET_YES;
-       GNUNET_CONTAINER_slist_next (&it), i--)
-  {
-    p = GNUNET_CONTAINER_slist_get (&it, &s);
-
-    if ((p == NULL) || (i != (j = *(int *) p)) || (s != sizeof (i)))
-    {
-      GNUNET_CONTAINER_slist_iter_destroy (&it);
-      GNUNET_assert (0);
-    }
-    j *= 2;
-    GNUNET_CONTAINER_slist_insert (&it,
-                                   
GNUNET_CONTAINER_SLIST_DISPOSITION_TRANSIENT,
-                                   &j, sizeof (j));
-  }
-  GNUNET_assert (GNUNET_CONTAINER_slist_count (l) == 200);
-  i = 198;
-  GNUNET_assert (GNUNET_CONTAINER_slist_contains (l, &i, sizeof (i)));
-
-  for (it = GNUNET_CONTAINER_slist_begin (l);
-       GNUNET_CONTAINER_slist_end (&it) != GNUNET_YES;)
-  {
-    p = GNUNET_CONTAINER_slist_get (&it, &s);
-    GNUNET_assert (p != NULL);
-    GNUNET_assert (s == sizeof (i));
-    i = *(int *) p;
-
-    GNUNET_assert (GNUNET_CONTAINER_slist_next (&it) == GNUNET_YES);
-    GNUNET_assert (GNUNET_CONTAINER_slist_end (&it) != GNUNET_YES);
-
-    p = GNUNET_CONTAINER_slist_get (&it, &s);
-    GNUNET_assert (p != NULL);
-    GNUNET_assert (s == sizeof (j));
-    j = *(int *) p;
-
-    GNUNET_assert (j * 2 == i);
-
-    GNUNET_CONTAINER_slist_erase (&it);
-  }
-  GNUNET_assert (GNUNET_CONTAINER_slist_count (l) == 100);
-  i = 99;
-  GNUNET_assert (GNUNET_CONTAINER_slist_contains (l, &i, sizeof (i)) ==
-                 GNUNET_NO);
-  i = 198;
-  GNUNET_assert (GNUNET_CONTAINER_slist_contains (l, &i, sizeof (i)) ==
-                 GNUNET_YES);
-
-  GNUNET_CONTAINER_slist_clear (l);
-  GNUNET_assert (GNUNET_CONTAINER_slist_count (l) == 0);
-
-  for (i = 0; i < 100; i++)
-    GNUNET_CONTAINER_slist_add (l, 
GNUNET_CONTAINER_SLIST_DISPOSITION_TRANSIENT,
-                                &i, sizeof (i));
-  /*check slist_append */
-  GNUNET_CONTAINER_slist_append (l, l);
-  GNUNET_assert (GNUNET_CONTAINER_slist_count (l) == 200);
-
-  GNUNET_CONTAINER_slist_destroy (l);
-
-  /*check slist_add_end */
-  l = GNUNET_CONTAINER_slist_create ();
-  for (i = 0; i < 100; i++)
-    GNUNET_CONTAINER_slist_add_end (l,
-                                    
GNUNET_CONTAINER_SLIST_DISPOSITION_TRANSIENT,
-                                    &i, sizeof (i));
-
-  GNUNET_assert (GNUNET_CONTAINER_slist_count (l) == 100);
-
-  for (it = GNUNET_CONTAINER_slist_begin (l), i = 0;
-       GNUNET_CONTAINER_slist_end (&it) != GNUNET_YES;
-       GNUNET_CONTAINER_slist_next (&it), i++)
-  {
-    p = GNUNET_CONTAINER_slist_get (&it, &s);
-
-    if ((p == NULL) || (i != *(int *) p) || (s != sizeof (i)))
-    {
-      GNUNET_assert (0);
-    }
-  }
-  GNUNET_CONTAINER_slist_destroy (l);
-
-  /*check if disp = GNUNET_CONTAINER_SLIST_DISPOSITION_DYNAMIC */
-  l = GNUNET_CONTAINER_slist_create ();
-
-  for (i = 0; i < 100; i++)
-  {
-    ip = GNUNET_new (int);
-    *ip = i;
-    GNUNET_CONTAINER_slist_add (l, GNUNET_CONTAINER_SLIST_DISPOSITION_DYNAMIC,
-                                ip, sizeof (int));
-  }
-  //creat_add
-  it = GNUNET_CONTAINER_slist_begin (l);
-  p = GNUNET_CONTAINER_slist_get (&it, &s);
-  GNUNET_assert (p != NULL);
-  //slist_erase
-  GNUNET_assert (GNUNET_CONTAINER_slist_next (&it) == GNUNET_YES);
-  GNUNET_CONTAINER_slist_erase (&it);
-  GNUNET_CONTAINER_slist_iter_destroy (&it);
-  GNUNET_assert (GNUNET_CONTAINER_slist_count (l) == 99);
-  //slist_clear
-  GNUNET_CONTAINER_slist_clear (l);
-  GNUNET_assert (GNUNET_CONTAINER_slist_count (l) == 0);
-  GNUNET_CONTAINER_slist_destroy (l);
-
-  return 0;
-}




reply via email to

[Prev in Thread] Current Thread [Next in Thread]