Added logic to the receiving side to ensure that the --delete-during
[rsync/rsync.git] / hashtable.c
index d1be1b8..1775a0b 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Routines to provide a memory-efficient hashtable.
  *
- * Copyright (C) 2007 Wayne Davison
+ * Copyright (C) 2007-2008 Wayne Davison
  *
  * 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
@@ -24,7 +24,7 @@
 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. */
@@ -41,6 +41,7 @@ struct hashtable *hashtable_create(int size, int key64)
        tbl->size = size;
        tbl->entries = 0;
        tbl->node_size = node_size;
+       tbl->key64 = (short)key64;
 
        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)
 {
-       int key64 = (tbl->node_size > sizeof (struct ht_int32_node));
+       int key64 = tbl->key64;
        struct ht_int32_node *node;
        uint32 ndx;
 
@@ -103,7 +104,9 @@ void *hashtable_find(struct hashtable *tbl, int64 key, int allocate_if_missing)
                a = b = c = 0xdeadbeef + (8 << 2);
 
 #define rot(x,k) (((x)<<(k)) ^ ((x)>>(32-(k))))
+#if SIZEOF_INT64 >= 8
                b += (uint32)(key >> 32);
+#endif
                a += (uint32)key;
                c ^= b; c -= rot(b, 14);
                a ^= c; a -= rot(c, 11);
@@ -139,7 +142,7 @@ void *hashtable_find(struct hashtable *tbl, int64 key, int allocate_if_missing)
        if (key64)
                ((struct ht_int64_node*)node)->key = key;
        else
-               node->key = key;
+               node->key = (int32)key;
        tbl->entries++;
        return node;
 }