[hipl-commit] [trunk] Rev 4461: Factorize repeating _LHASH cast pattern.

  • From: Diego Biurrun <diego@xxxxxxxxxx>
  • To: hipl-commit@xxxxxxxxxxxxx
  • Date: Tue, 4 May 2010 13:24:21 +0300

Committer: Diego Biurrun <diego@xxxxxxxxxx>
Date: 04/05/2010 at 13:24:21
Revision: 4461
Revision-id: diego@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Branch nick: trunk

Log:
  Factorize repeating _LHASH cast pattern.

Modified:
  M  lib/core/list.h

=== modified file 'lib/core/list.h'
--- lib/core/list.h     2010-04-26 18:13:19 +0000
+++ lib/core/list.h     2010-05-04 10:24:04 +0000
@@ -9,6 +9,12 @@
 
 #include <openssl/lhash.h>
 
+#ifdef LHASH_OF
+#define LHASH_CAST (_LHASH *)
+#else
+#define LHASH_CAST
+#endif
+
 typedef LHASH_NODE hip_list_t;
 
 /**
@@ -24,11 +30,7 @@
  * @param entry the entry to find from the list
  * @param head the head for your list.
  */
-#ifdef LHASH_OF
-#define list_find(entry, head) lh_retrieve((_LHASH *) head, entry)
-#else
-#define list_find(entry, head) lh_retrieve(head, entry)
-#endif
+#define list_find(entry, head) lh_retrieve(LHASH_CAST head, entry)
 
 /**
  * list_for_each - iterate over list of given type
@@ -60,11 +62,7 @@
  * Insert a new entry after the specified head.
  * This is good for implementing stacks.
  */
-#ifdef LHASH_OF
-#define list_add(entry, head) lh_insert((_LHASH *) head, entry)
-#else
-#define list_add(entry, head) lh_insert(head, entry)
-#endif
+#define list_add(entry, head) lh_insert(LHASH_CAST head, entry)
 
 /**
  * list_del - deletes entry from list.
@@ -72,10 +70,6 @@
  * Note: list_empty on entry does not return true after this, the entry is
  * in an undefined state.
  */
-#ifdef LHASH_OF
-#define list_del(entry, head) lh_delete((_LHASH *) head, entry)
-#else
-#define list_del(entry, head) lh_delete(head, entry)
-#endif
+#define list_del(entry, head) lh_delete(LHASH_CAST head, entry)
 
 #endif /* HIP_LIB_CORE_LIST_H */

Other related posts:

  • » [hipl-commit] [trunk] Rev 4461: Factorize repeating _LHASH cast pattern. - Diego Biurrun