[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r8776: r9304@dhcp-18-188-67-85: nickm | 2006-10-20 12:22:46 -0400 C (in tor/trunk: . src/common src/or)
- To: or-cvs@xxxxxxxxxxxxx
- Subject: [or-cvs] r8776: r9304@dhcp-18-188-67-85: nickm | 2006-10-20 12:22:46 -0400 C (in tor/trunk: . src/common src/or)
- From: nickm@xxxxxxxx
- Date: Fri, 20 Oct 2006 12:22:55 -0400 (EDT)
- Delivered-to: archiver@seul.org
- Delivered-to: or-cvs-outgoing@seul.org
- Delivered-to: or-cvs@seul.org
- Delivery-date: Fri, 20 Oct 2006 12:23:06 -0400
- Reply-to: or-talk@xxxxxxxxxxxxx
- Sender: owner-or-cvs@xxxxxxxxxxxxx
Author: nickm
Date: 2006-10-20 12:22:53 -0400 (Fri, 20 Oct 2006)
New Revision: 8776
Modified:
tor/trunk/
tor/trunk/src/common/container.c
tor/trunk/src/common/ht.h
tor/trunk/src/or/dns.c
Log:
r9304@dhcp-18-188-67-85: nickm | 2006-10-20 12:22:46 -0400
Change HT_INIT from a special-case to a macro-calling-a-function like the rest of ht.h. This might prevent errors if somebody did, I dunno, "HT_INIT(tp, hashtable++)". Based on a patch from Watson Ladd.
Property changes on: tor/trunk
___________________________________________________________________
svk:merge ticket from /tor/trunk [r9304] on c95137ef-5f19-0410-b913-86e773d04f59
Modified: tor/trunk/src/common/container.c
===================================================================
--- tor/trunk/src/common/container.c 2006-10-20 15:59:26 UTC (rev 8775)
+++ tor/trunk/src/common/container.c 2006-10-20 16:22:53 UTC (rev 8776)
@@ -675,7 +675,7 @@
{
strmap_t *result;
result = tor_malloc(sizeof(strmap_t));
- HT_INIT(&result->head);
+ HT_INIT(strmap_impl, &result->head);
return result;
}
@@ -686,7 +686,7 @@
{
digestmap_t *result;
result = tor_malloc(sizeof(digestmap_t));
- HT_INIT(&result->head);
+ HT_INIT(digestmap_impl, &result->head);
return result;
}
Modified: tor/trunk/src/common/ht.h
===================================================================
--- tor/trunk/src/common/ht.h 2006-10-20 15:59:26 UTC (rev 8775)
+++ tor/trunk/src/common/ht.h 2006-10-20 16:22:53 UTC (rev 8776)
@@ -26,14 +26,6 @@
#define HT_INITIALIZER() \
{ NULL, 0, 0, 0, -1 }
-#define HT_INIT(root) do { \
- (root)->hth_table_length = 0; \
- (root)->hth_table = NULL; \
- (root)->hth_n_entries = 0; \
- (root)->hth_load_limit = 0; \
- (root)->hth_prime_idx = -1; \
- } while (0)
-
#define HT_ENTRY(type) \
struct { \
struct type *hte_next; \
@@ -59,7 +51,7 @@
#define HT_NEXT(name, head, elm) name##_HT_NEXT((head), (elm))
#define HT_NEXT_RMV(name, head, elm) name##_HT_NEXT_RMV((head), (elm))
#define HT_CLEAR(name, head) name##_HT_CLEAR(head)
-
+#define HT_INIT(name, head) name##_HT_INIT(head)
/* Helper: */
static INLINE unsigned
ht_improve_hash(unsigned h)
@@ -100,6 +92,14 @@
int name##_HT_GROW(struct name *ht, unsigned min_capacity); \
void name##_HT_CLEAR(struct name *ht); \
int _##name##_HT_REP_IS_BAD(struct name *ht); \
+ static INLINE void \
+ name##_HT_INIT(struct name *head) { \
+ head->hth_table_length = 0; \
+ head->hth_table = NULL; \
+ head->hth_n_entries = 0; \
+ head->hth_load_limit = 0; \
+ head->hth_prime_idx = -1; \
+ } \
/* Helper: returns a pointer to the right location in the table \
* 'head' to find or insert the element 'elm'. */ \
static INLINE struct type ** \
@@ -344,7 +344,7 @@
if (head->hth_table) \
freefn(head->hth_table); \
head->hth_table_length = 0; \
- HT_INIT(head); \
+ name##_HT_INIT(head); \
} \
/* Debugging helper: return false iff the representation of 'head' is \
* internally consistent. */ \
Modified: tor/trunk/src/or/dns.c
===================================================================
--- tor/trunk/src/or/dns.c 2006-10-20 15:59:26 UTC (rev 8775)
+++ tor/trunk/src/or/dns.c 2006-10-20 16:22:53 UTC (rev 8776)
@@ -162,7 +162,7 @@
static void
init_cache_map(void)
{
- HT_INIT(&cache_root);
+ HT_INIT(cache_map, &cache_root);
}
#ifdef USE_EVENTDNS