summaryrefslogtreecommitdiff
path: root/plugins/MirOTR/ekhtml/include/hash.h
diff options
context:
space:
mode:
authorRené Schümann <white06tiger@gmail.com>2015-03-20 12:30:48 +0000
committerRené Schümann <white06tiger@gmail.com>2015-03-20 12:30:48 +0000
commit90171f125f36488dc08f5cfe0b0d4b78d995f08d (patch)
treee65a38bd8ba391fc800cecc896379a7fb76a0608 /plugins/MirOTR/ekhtml/include/hash.h
parent190307ca7aee92d6b862db0bf78cde10acfc95d0 (diff)
MirOTR: updated ekhtml from 0.3.2 to 0.3.3-pre (Git 0092d9d), this fixes a memory leak and improves attribute parsing
git-svn-id: http://svn.miranda-ng.org/main/trunk@12448 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/MirOTR/ekhtml/include/hash.h')
-rw-r--r--plugins/MirOTR/ekhtml/include/hash.h31
1 files changed, 27 insertions, 4 deletions
diff --git a/plugins/MirOTR/ekhtml/include/hash.h b/plugins/MirOTR/ekhtml/include/hash.h
index ddb3869477..5b6333e264 100644
--- a/plugins/MirOTR/ekhtml/include/hash.h
+++ b/plugins/MirOTR/ekhtml/include/hash.h
@@ -14,8 +14,6 @@
* into proprietary software; there is no requirement for such software to
* contain a copyright notice related to this source.
*
- * $Id: hash.h,v 1.1 2002/09/17 02:49:36 jick Exp $
- * $Name: EKHTML_RELEASE_0_3_2 $
*/
#ifndef HASH_H
@@ -40,8 +38,6 @@ typedef unsigned long hashcount_t;
typedef unsigned long hash_val_t;
#define HASH_VAL_T_MAX ULONG_MAX
-extern int hash_val_t_bit;
-
#ifndef HASH_VAL_T_BIT
#define HASH_VAL_T_BIT ((int) hash_val_t_bit)
#endif
@@ -233,6 +229,33 @@ extern void hnode_destroy(hnode_t *);
#define hnode_put(N, V) ((N)->hash_data = (V))
#endif
+/*
+ * Compute the number of bits in the hash_val_t type. We know that hash_val_t
+ * is an unsigned integral type. Thus the highest value it can hold is a
+ * Mersenne number (power of two, less one). We initialize a hash_val_t
+ * object with this value and then shift bits out one by one while counting.
+ * Notes:
+ * 1. HASH_VAL_T_MAX is a Mersenne number---one that is one less than a power
+ * of two. This means that its binary representation consists of all one
+ * bits, and hence ``val'' is initialized to all one bits.
+ * 2. While bits remain in val, we increment the bit count and shift it to the
+ * right, replacing the topmost bit by zero.
+ */
+
+static int compute_bits(void)
+{
+ hash_val_t val = HASH_VAL_T_MAX; /* 1 */
+ int bits = 0;
+
+ while (val) { /* 2 */
+ bits++;
+ val >>= 1;
+ }
+
+ return bits;
+}
+
+
#ifdef __cplusplus
}
#endif