Store the key64 flag from hashtable_create() in the hashtable structure
authorWayne Davison <wayned@samba.org>
Mon, 4 Feb 2008 15:29:22 +0000 (07:29 -0800)
committerWayne Davison <wayned@samba.org>
Mon, 4 Feb 2008 15:29:22 +0000 (07:29 -0800)
so that hashtable_find() knows which hashtable is which on a 64-bit
architecture.

hashtable.c
rsync.h

index d1be1b8..c5ba0f5 100644 (file)
@@ -24,7 +24,7 @@
 struct hashtable *hashtable_create(int size, int key64)
 {
        struct hashtable *tbl;
 struct hashtable *hashtable_create(int size, int key64)
 {
        struct hashtable *tbl;
-       int node_size = key64 ? sizeof (struct ht_int64_node )
+       int node_size = key64 ? sizeof (struct ht_int64_node)
                              : sizeof (struct ht_int32_node);
 
        /* Pick a power of 2 that can hold the requested size. */
                              : sizeof (struct ht_int32_node);
 
        /* Pick a power of 2 that can hold the requested size. */
@@ -41,6 +41,7 @@ struct hashtable *hashtable_create(int size, int key64)
        tbl->size = size;
        tbl->entries = 0;
        tbl->node_size = node_size;
        tbl->size = size;
        tbl->entries = 0;
        tbl->node_size = node_size;
+       tbl->key64 = key64;
 
        return tbl;
 }
 
        return tbl;
 }
@@ -55,7 +56,7 @@ void hashtable_destroy(struct hashtable *tbl)
  * already existing.  Returns NULL if not allocating and not found. */
 void *hashtable_find(struct hashtable *tbl, int64 key, int allocate_if_missing)
 {
  * already existing.  Returns NULL if not allocating and not found. */
 void *hashtable_find(struct hashtable *tbl, int64 key, int allocate_if_missing)
 {
-       int key64 = (tbl->node_size > sizeof (struct ht_int32_node));
+       int key64 = tbl->key64;
        struct ht_int32_node *node;
        uint32 ndx;
 
        struct ht_int32_node *node;
        uint32 ndx;
 
diff --git a/rsync.h b/rsync.h
index 2592230..092cc99 100644 (file)
--- a/rsync.h
+++ b/rsync.h
@@ -540,6 +540,7 @@ struct hashtable {
        void *nodes;
        int32 size, entries;
        uint32 node_size;
        void *nodes;
        int32 size, entries;
        uint32 node_size;
+       int key64;
 };
 
 struct ht_int32_node {
 };
 
 struct ht_int32_node {