[tor-commits] [tor/master] Make ht.h conform to Tor's code style again

nickm at torproject.org nickm at torproject.org
Tue Feb 14 16:05:38 UTC 2012


commit efcdc930fb02d471ef1a5f4c09a30ea512ca5a8b
Author: Sebastian Hahn <sebastian at torproject.org>
Date:   Tue Feb 14 11:13:06 2012 +0100

    Make ht.h conform to Tor's code style again
    
    When porting over changes from libevent, a bunch of tabs and a couple of
    long lines got introduced.
---
 src/common/ht.h |   48 +++++++++++++++++++++++++-----------------------
 1 files changed, 25 insertions(+), 23 deletions(-)

diff --git a/src/common/ht.h b/src/common/ht.h
index f7d4ce1..0783cb1 100644
--- a/src/common/ht.h
+++ b/src/common/ht.h
@@ -103,23 +103,24 @@ ht_string_hash(const char *s)
 
 #ifndef HT_NO_CACHE_HASH_VALUES
 #define HT_SET_HASH_(elm, field, hashfn)        \
-	do { (elm)->field.hte_hash = hashfn(elm); } while (0)
-#define HT_SET_HASHVAL_(elm, field, val)	\
-	do { (elm)->field.hte_hash = (val); } while (0)
-#define HT_ELT_HASH_(elm, field, hashfn)	\
-	((elm)->field.hte_hash)
+    do { (elm)->field.hte_hash = hashfn(elm); } while (0)
+#define HT_SET_HASHVAL_(elm, field, val)        \
+    do { (elm)->field.hte_hash = (val); } while (0)
+#define HT_ELT_HASH_(elm, field, hashfn)        \
+    ((elm)->field.hte_hash)
 #else
-#define HT_SET_HASH_(elm, field, hashfn)	\
-	((void)0)
-#define HT_ELT_HASH_(elm, field, hashfn)	\
-	(hashfn(elm))
-#define HT_SET_HASHVAL_(elm, field, val)	\
+#define HT_SET_HASH_(elm, field, hashfn)        \
+    ((void)0)
+#define HT_ELT_HASH_(elm, field, hashfn)        \
+    (hashfn(elm))
+#define HT_SET_HASHVAL_(elm, field, val)        \
         ((void)0)
 #endif
 
 /* Helper: alias for the bucket containing 'elm'. */
-#define HT_BUCKET_(head, field, elm, hashfn)				\
-	((head)->hth_table[HT_ELT_HASH_(elm,field,hashfn) % head->hth_table_length])
+#define HT_BUCKET_(head, field, elm, hashfn)                            \
+    ((head)->hth_table[HT_ELT_HASH_(elm,field,hashfn)                   \
+        % head->hth_table_length])
 
 #define HT_FOREACH(x, name, head)                 \
   for ((x) = HT_START(name, head);                \
@@ -129,7 +130,7 @@ ht_string_hash(const char *s)
 #define HT_PROTOTYPE(name, type, field, hashfn, eqfn)                   \
   int name##_HT_GROW(struct name *ht, unsigned min_capacity);           \
   void name##_HT_CLEAR(struct name *ht);                                \
-  int name##_HT_REP_IS_BAD_(const struct name *ht);			\
+  int name##_HT_REP_IS_BAD_(const struct name *ht);                     \
   static INLINE void                                                    \
   name##_HT_INIT(struct name *head) {                                   \
     head->hth_table_length = 0;                                         \
@@ -141,12 +142,12 @@ ht_string_hash(const char *s)
   /* Helper: returns a pointer to the right location in the table       \
    * 'head' to find or insert the element 'elm'. */                     \
   static INLINE struct type **                                          \
-  name##_HT_FIND_P_(struct name *head, struct type *elm)		\
+  name##_HT_FIND_P_(struct name *head, struct type *elm)                \
   {                                                                     \
     struct type **p;                                                    \
     if (!head->hth_table)                                               \
       return NULL;                                                      \
-    p = &HT_BUCKET_(head, field, elm, hashfn);				\
+    p = &HT_BUCKET_(head, field, elm, hashfn);                          \
     while (*p) {                                                        \
       if (eqfn(*p, elm))                                                \
         return p;                                                       \
@@ -162,7 +163,7 @@ ht_string_hash(const char *s)
     struct type **p;                                                    \
     struct name *h = (struct name *) head;                              \
     HT_SET_HASH_(elm, field, hashfn);                                   \
-    p = name##_HT_FIND_P_(h, elm);					\
+    p = name##_HT_FIND_P_(h, elm);                                      \
     return p ? *p : NULL;                                               \
   }                                                                     \
   /* Insert the element 'elm' into the table 'head'.  Do not call this  \
@@ -175,7 +176,7 @@ ht_string_hash(const char *s)
       name##_HT_GROW(head, head->hth_n_entries+1);                      \
     ++head->hth_n_entries;                                              \
     HT_SET_HASH_(elm, field, hashfn);                                   \
-    p = &HT_BUCKET_(head, field, elm, hashfn);				\
+    p = &HT_BUCKET_(head, field, elm, hashfn);                          \
     elm->field.hte_next = *p;                                           \
     *p = elm;                                                           \
   }                                                                     \
@@ -189,7 +190,7 @@ ht_string_hash(const char *s)
     if (!head->hth_table || head->hth_n_entries >= head->hth_load_limit) \
       name##_HT_GROW(head, head->hth_n_entries+1);                      \
     HT_SET_HASH_(elm, field, hashfn);                                   \
-    p = name##_HT_FIND_P_(head, elm);					\
+    p = name##_HT_FIND_P_(head, elm);                                   \
     r = *p;                                                             \
     *p = elm;                                                           \
     if (r && (r!=elm)) {                                                \
@@ -208,7 +209,7 @@ ht_string_hash(const char *s)
   {                                                                     \
     struct type **p, *r;                                                \
     HT_SET_HASH_(elm, field, hashfn);                                   \
-    p = name##_HT_FIND_P_(head,elm);					\
+    p = name##_HT_FIND_P_(head,elm);                                    \
     if (!p || !*p)                                                      \
       return NULL;                                                      \
     r = *p;                                                             \
@@ -269,7 +270,8 @@ ht_string_hash(const char *s)
     if ((*elm)->field.hte_next) {                                       \
       return &(*elm)->field.hte_next;                                   \
     } else {                                                            \
-      unsigned b = (HT_ELT_HASH_(*elm, field, hashfn) % head->hth_table_length)+1; \
+      unsigned b = (HT_ELT_HASH_(*elm, field, hashfn)                   \
+      % head->hth_table_length)+1;                                      \
       while (b < head->hth_table_length) {                              \
         if (head->hth_table[b])                                         \
           return &head->hth_table[b];                                   \
@@ -281,7 +283,7 @@ ht_string_hash(const char *s)
   static INLINE struct type **                                          \
   name##_HT_NEXT_RMV(struct name *head, struct type **elm)              \
   {                                                                     \
-    unsigned h = HT_ELT_HASH_(*elm, field, hashfn);		        \
+    unsigned h = HT_ELT_HASH_(*elm, field, hashfn);                     \
     *elm = (*elm)->field.hte_next;                                      \
     --head->hth_n_entries;                                              \
     if (*elm) {                                                         \
@@ -386,7 +388,7 @@ ht_string_hash(const char *s)
   /* Debugging helper: return false iff the representation of 'head' is \
    * internally consistent. */                                          \
   int                                                                   \
-  name##_HT_REP_IS_BAD_(const struct name *head)			\
+  name##_HT_REP_IS_BAD_(const struct name *head)                        \
   {                                                                     \
     unsigned n, i;                                                      \
     struct type *elm;                                                   \
@@ -408,7 +410,7 @@ ht_string_hash(const char *s)
       return 5;                                                         \
     for (n = i = 0; i < head->hth_table_length; ++i) {                  \
       for (elm = head->hth_table[i]; elm; elm = elm->field.hte_next) {  \
-        if (HT_ELT_HASH_(elm, field, hashfn) != hashfn(elm))	        \
+        if (HT_ELT_HASH_(elm, field, hashfn) != hashfn(elm))            \
           return 1000 + i;                                              \
         if ((HT_ELT_HASH_(elm, field, hashfn) % head->hth_table_length) != i) \
           return 10000 + i;                                             \



More information about the tor-commits mailing list