Merged silc_1_1_branch to trunk.
[silc.git] / lib / silcutil / silcdlist.h
index cb46c82f303b825bb9202ef7ae03c3d002bb2dbb..87dfb4cce6cb26871b4602d23153cd55a0e8934d 100644 (file)
@@ -4,7 +4,7 @@
 
   Author: Pekka Riikonen <priikone@silcnet.org>
 
-  Copyright (C) 2000 - 2005 Pekka Riikonen
+  Copyright (C) 2000 - 2007 Pekka Riikonen
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
  * will automatically allocate list entries.  Normal SILC List API cannot
  * be used for this purpose because in that case the context passed to the
  * list must be defined as list structure already.  This is not the case in
- * SilcDList.  But SilcDList is a bit slower than SilcList because it 
+ * SilcDList.  But SilcDList is a bit slower than SilcList because it
  * requires memory allocation when adding new entries to the list.
  *
- * SILC Dynamic List is not thread-safe.  If the same list context must be 
+ * SILC Dynamic List is not thread-safe.  If the same list context must be
  * used in multithreaded environment concurrency control must be employed.
  *
  ***/
  *    Application defines this object and adds contexts to this list with
  *    Dynamic List Interface functions.
  *
- * SOURCE
- */
+ ***/
 typedef struct SilcDListStruct {
   SilcList list;
   void *current;
   void *prev;
 } *SilcDList;
-/***/
 
 /* SilcDListEntry structure, one entry in the list. This MUST NOT be used
    directly by the application. */
@@ -201,7 +199,7 @@ static inline
 SilcBool silc_dlist_add(SilcDList list, void *context)
 {
   SilcDListEntry e = (SilcDListEntry)silc_malloc(sizeof(*e));
-  if (!e)
+  if (silc_unlikely(!e))
     return FALSE;
   e->context = context;
   silc_list_add(list->list, e);
@@ -227,7 +225,7 @@ static inline
 SilcBool silc_dlist_insert(SilcDList list, void *context)
 {
   SilcDListEntry e = (SilcDListEntry)silc_malloc(sizeof(*e));
-  if (!e)
+  if (silc_unlikely(!e))
     return FALSE;
   e->context = context;
   silc_list_insert(list->list, list->prev, e);
@@ -239,22 +237,22 @@ SilcBool silc_dlist_insert(SilcDList list, void *context)
  * SYNOPSIS
  *
  *    static inline
- *    void silc_dlist_del(SilcDList list, void *context);
+ *    void silc_dlist_del(SilcDList list, void *entry);
  *
  * DESCRIPTION
  *
- *    Remove entry from the list. Returns < 0 on error, 0 otherwise.
+ *    Remove entry from the list.
  *
  ***/
 
 static inline
-void silc_dlist_del(SilcDList list, void *context)
+void silc_dlist_del(SilcDList list, void *entry)
 {
   SilcDListEntry e;
 
   silc_list_start(list->list);
   while ((e = (SilcDListEntry)silc_list_get(list->list)) != SILC_LIST_END) {
-    if (e->context == context) {
+    if (e->context == entry) {
       silc_list_del(list->list, e);
 #if defined(SILC_DEBUG)
       memset(e, 'F', sizeof(*e));