dovecot-2.2: Reverted some of the last hash table changes.
dovecot at dovecot.org
dovecot at dovecot.org
Wed Aug 29 08:56:54 EEST 2012
details: http://hg.dovecot.org/dovecot-2.2/rev/9ae214349fac
changeset: 14965:9ae214349fac
user: Timo Sirainen <tss at iki.fi>
date: Wed Aug 29 08:56:40 2012 +0300
description:
Reverted some of the last hash table changes.
They caused hash table operations to dereference pointers, which caused
a compiler error if the type wasn't known.
diffstat:
src/lib/hash-decl.h | 3 +++
src/lib/hash.h | 19 +++++++++----------
2 files changed, 12 insertions(+), 10 deletions(-)
diffs (77 lines):
diff -r 6d2be8d8891c -r 9ae214349fac src/lib/hash-decl.h
--- a/src/lib/hash-decl.h Tue Aug 28 22:40:57 2012 +0300
+++ b/src/lib/hash-decl.h Wed Aug 29 08:56:40 2012 +0300
@@ -4,7 +4,10 @@
#define HASH_TABLE_UNION(key_type, value_type) { \
struct hash_table *_table; \
key_type _key; \
+ key_type *_keyp; \
+ const key_type _const_key; \
value_type _value; \
+ value_type *_valuep; \
}
#define HASH_TABLE_DEFINE_TYPE(name, key_type, value_type) \
diff -r 6d2be8d8891c -r 9ae214349fac src/lib/hash.h
--- a/src/lib/hash.h Tue Aug 28 22:40:57 2012 +0300
+++ b/src/lib/hash.h Wed Aug 29 08:56:40 2012 +0300
@@ -31,13 +31,12 @@
!__builtin_types_compatible_p(typeof(&key_cmp_cb), \
int (*)(typeof((*table)._key), typeof((*table)._key))) && \
!__builtin_types_compatible_p(typeof(&key_cmp_cb), \
- int (*)(typeof(const typeof(*(*table)._key) *), \
- typeof(const typeof(*(*table)._key) *)))); \
+ int (*)(typeof((*table)._const_key), typeof((*table)._const_key)))); \
(void)COMPILE_ERROR_IF_TRUE( \
!__builtin_types_compatible_p(typeof(&hash_cb), \
unsigned int (*)(typeof((*table)._key))) && \
!__builtin_types_compatible_p(typeof(&hash_cb), \
- unsigned int (*)(typeof(const typeof(*(*table)._key) *)))); \
+ unsigned int (*)(typeof((*table)._const_key)))); \
hash_table_create(&(*table)._table, pool, size, \
(hash_callback_t *)hash_cb, \
(hash_cmp_callback_t *)key_cmp_cb);})
@@ -78,17 +77,17 @@
void *hash_table_lookup(const struct hash_table *table, const void *key) ATTR_PURE;
#define hash_table_lookup(table, key) \
HASH_VALUE_CAST(table)hash_table_lookup((table)._table, \
- (const void *)((const char *)(key) + COMPILE_ERROR_IF_TYPES_NOT_COMPATIBLE(*(table)._key, *key)))
+ (const void *)((const char *)(key) + COMPILE_ERROR_IF_TYPES2_NOT_COMPATIBLE((table)._key, (table)._const_key, key)))
bool hash_table_lookup_full(const struct hash_table *table,
const void *lookup_key,
void **orig_key_r, void **value_r);
#define hash_table_lookup_full(table, lookup_key, orig_key_r, value_r) \
hash_table_lookup_full((table)._table, \
- (void *)((const char *)(lookup_key) + COMPILE_ERROR_IF_TYPES_NOT_COMPATIBLE(*(table)._key, *lookup_key)), \
- (void **)(void *)((orig_key_r) + COMPILE_ERROR_IF_TYPES_NOT_COMPATIBLE((table)._key, *orig_key_r) + \
+ (void *)((const char *)(lookup_key) + COMPILE_ERROR_IF_TYPES2_NOT_COMPATIBLE((table)._const_key, (table)._key, lookup_key)), \
+ (void **)(void *)((orig_key_r) + COMPILE_ERROR_IF_TYPES_NOT_COMPATIBLE((table)._keyp, orig_key_r) + \
COMPILE_ERROR_IF_TRUE(sizeof(*orig_key_r) != sizeof(void *))), \
- (void **)(void *)((value_r) + COMPILE_ERROR_IF_TYPES_NOT_COMPATIBLE((table)._value, *value_r) + \
+ (void **)(void *)((value_r) + COMPILE_ERROR_IF_TYPES_NOT_COMPATIBLE((table)._valuep, value_r) + \
COMPILE_ERROR_IF_TRUE(sizeof(*value_r) != sizeof(void *))))
/* Insert/update node in hash table. The difference is that hash_table_insert()
@@ -107,7 +106,7 @@
void hash_table_remove(struct hash_table *table, const void *key);
#define hash_table_remove(table, key) \
hash_table_remove((table)._table, \
- (const void *)((const char *)(key) + COMPILE_ERROR_IF_TYPES_NOT_COMPATIBLE(*(table)._key, *key)))
+ (const void *)((const char *)(key) + COMPILE_ERROR_IF_TYPES2_NOT_COMPATIBLE((table)._const_key, (table)._key, key)))
unsigned int hash_table_count(const struct hash_table *table) ATTR_PURE;
#define hash_table_count(table) \
hash_table_count((table)._table)
@@ -122,10 +121,10 @@
void **key_r, void **value_r);
#define hash_table_iterate(ctx, table, key_r, value_r) \
hash_table_iterate(ctx, \
- (void **)(void *)((key_r) + COMPILE_ERROR_IF_TYPES_NOT_COMPATIBLE((table)._key, *key_r) + \
+ (void **)(void *)((key_r) + COMPILE_ERROR_IF_TYPES_NOT_COMPATIBLE((table)._keyp, key_r) + \
COMPILE_ERROR_IF_TRUE(sizeof(*key_r) != sizeof(void *)) + \
COMPILE_ERROR_IF_TRUE(sizeof(*value_r) != sizeof(void *))), \
- (void **)(void *)((value_r) + COMPILE_ERROR_IF_TYPES_NOT_COMPATIBLE((table)._value, *value_r)))
+ (void **)(void *)((value_r) + COMPILE_ERROR_IF_TYPES_NOT_COMPATIBLE((table)._valuep, value_r)))
void hash_table_iterate_deinit(struct hash_iterate_context **ctx);
/* Hash table isn't resized, and removed nodes aren't removed from
More information about the dovecot-cvs
mailing list