changeset 14923:96fd2c3bf932

Reverted "support for non-pointers" part of the hash table API changes. Originally I wrote it using clang, which didn't give as many warnings as gcc did. I guess this way is safer anyway..
author Timo Sirainen <tss@iki.fi>
date Mon, 20 Aug 2012 09:47:28 +0300
parents edb1d5babfcd
children 6c55e57c98a1
files src/anvil/connect-limit.c src/auth/auth-request-handler.c src/auth/db-checkpassword.c src/auth/db-ldap.c src/auth/db-passwd-file.c src/director/director-test.c src/director/user-directory.c src/doveadm/doveadm-director.c src/doveadm/doveadm-kick.c src/doveadm/doveadm-log.c src/doveadm/doveadm-mail-server.c src/doveadm/doveadm-stats.c src/doveadm/doveadm-who.c src/doveadm/dsync/dsync-mailbox-export.c src/doveadm/dsync/dsync-mailbox-import.c src/doveadm/dsync/dsync-transaction-log-scan.c src/doveadm/dsync/dsync-transaction-log-scan.h src/imap/imap-client.c src/lib-auth/auth-server-connection.c src/lib-auth/auth-server-connection.h src/lib-dict/dict-file.c src/lib-index/mail-cache-fields.c src/lib-index/mail-cache-private.h src/lib-index/mail-index-private.h src/lib-index/mail-index.c src/lib-lda/duplicate.c src/lib-master/master-auth.c src/lib-master/master-login-auth.c src/lib-settings/settings-parser.c src/lib-storage/index/dbox-multi/mdbox-purge.c src/lib-storage/index/index-thread-finish.c src/lib-storage/index/maildir/maildir-keywords.c src/lib-storage/list/mailbox-list-index-sync.c src/lib-storage/list/mailbox-list-index.c src/lib-storage/list/mailbox-list-index.h src/lib/child-wait.c src/lib/hash.c src/lib/hash.h src/log/log-connection.c src/login-common/ssl-proxy-openssl.c src/master/service-monitor.c src/master/service-process.c src/master/service.c src/master/service.h src/plugins/acl/acl-cache.c src/plugins/expire/doveadm-expire.c src/plugins/fts-lucene/lucene-wrapper.cc src/plugins/fts/fts-expunge-log.c src/pop3/pop3-commands.c src/replication/aggregator/replicator-connection.c
diffstat 50 files changed, 282 insertions(+), 280 deletions(-) [+]
line wrap: on
line diff
--- a/src/anvil/connect-limit.c	Mon Aug 20 08:31:00 2012 +0300
+++ b/src/anvil/connect-limit.c	Mon Aug 20 09:47:28 2012 +0300
@@ -15,8 +15,8 @@
 };
 
 struct connect_limit {
-	/* ident => refcount */
-	HASH_TABLE(char *, unsigned int) ident_hash;
+	/* ident => unsigned int refcount */
+	HASH_TABLE(char *, void *) ident_hash;
 	/* struct ident_pid => struct ident_pid */
 	HASH_TABLE(struct ident_pid *, struct ident_pid *) ident_pid_hash;
 };
@@ -60,24 +60,26 @@
 unsigned int connect_limit_lookup(struct connect_limit *limit,
 				  const char *ident)
 {
-	return hash_table_lookup(limit->ident_hash, ident);
+	void *value;
+
+	value = hash_table_lookup(limit->ident_hash, ident);
+	return POINTER_CAST_TO(value, unsigned int);
 }
 
 void connect_limit_connect(struct connect_limit *limit, pid_t pid,
 			   const char *ident)
 {
 	struct ident_pid *i, lookup_i;
-	void *orig_key, *orig_value;
 	char *key;
-	unsigned int value;
+	void *value;
 
 	if (!hash_table_lookup_full(limit->ident_hash, ident,
-				    &orig_key, &orig_value)) {
+				    &key, &value)) {
 		key = i_strdup(ident);
-		hash_table_insert(limit->ident_hash, key, 1U);
+		value = POINTER_CAST(1);
+		hash_table_insert(limit->ident_hash, key, value);
 	} else {
-		key = orig_key;
-		value = POINTER_CAST_TO(orig_value, unsigned int) + 1;
+		value = POINTER_CAST(POINTER_CAST_TO(value, unsigned int) + 1);
 		hash_table_update(limit->ident_hash, key, value);
 	}
 
@@ -98,18 +100,17 @@
 static void
 connect_limit_ident_hash_unref(struct connect_limit *limit, const char *ident)
 {
-	void *orig_key, *orig_value;
 	char *key;
+	void *value;
 	unsigned int new_refcount;
 
-	if (!hash_table_lookup_full(limit->ident_hash, ident,
-				    &orig_key, &orig_value))
+	if (!hash_table_lookup_full(limit->ident_hash, ident, &key, &value))
 		i_panic("connect limit hash tables are inconsistent");
 
-	key = orig_key;
-	new_refcount = POINTER_CAST_TO(orig_value, unsigned int) - 1;
+	new_refcount = POINTER_CAST_TO(value, unsigned int) - 1;
 	if (new_refcount > 0) {
-		hash_table_update(limit->ident_hash, key, new_refcount);
+		value = POINTER_CAST(new_refcount);
+		hash_table_update(limit->ident_hash, key, value);
 	} else {
 		hash_table_remove(limit->ident_hash, key);
 		i_free(key);
@@ -147,7 +148,7 @@
 	/* this should happen rarely (or never), so this slow implementation
 	   should be fine. */
 	iter = hash_table_iterate_init(limit->ident_pid_hash);
-	while (hash_table_iterate_t(iter, limit->ident_pid_hash, &i, &value)) {
+	while (hash_table_iterate(iter, limit->ident_pid_hash, &i, &value)) {
 		if (i->pid == pid) {
 			hash_table_remove(limit->ident_pid_hash, i);
 			for (; i->refcount > 0; i->refcount--)
@@ -165,7 +166,7 @@
 	string_t *str = t_str_new(256);
 
 	iter = hash_table_iterate_init(limit->ident_pid_hash);
-	while (hash_table_iterate_t(iter, limit->ident_pid_hash, &i, &value)) {
+	while (hash_table_iterate(iter, limit->ident_pid_hash, &i, &value)) {
 		str_truncate(str, 0);
 		str_tabescape_write(str, i->ident);
 		str_printfa(str, "\t%ld\t%u\n", (long)i->pid, i->refcount);
--- a/src/auth/auth-request-handler.c	Mon Aug 20 08:31:00 2012 +0300
+++ b/src/auth/auth-request-handler.c	Mon Aug 20 09:47:28 2012 +0300
@@ -21,7 +21,7 @@
 struct auth_request_handler {
 	int refcount;
 	pool_t pool;
-	HASH_TABLE(unsigned int, struct auth_request *) requests;
+	HASH_TABLE(void *, struct auth_request *) requests;
 
         unsigned int connect_uid, client_pid;
 
@@ -68,19 +68,17 @@
 void auth_request_handler_abort_requests(struct auth_request_handler *handler)
 {
 	struct hash_iterate_context *iter;
-	void *key, *value;
+	void *key;
+	struct auth_request *auth_request;
 
 	iter = hash_table_iterate_init(handler->requests);
-	while (hash_table_iterate(iter, &key, &value)) {
-		unsigned int id = POINTER_CAST_TO(key, unsigned int);
-		struct auth_request *auth_request = value;
-
+	while (hash_table_iterate(iter, handler->requests, &key, &auth_request)) {
 		switch (auth_request->state) {
 		case AUTH_REQUEST_STATE_NEW:
 		case AUTH_REQUEST_STATE_MECH_CONTINUE:
 		case AUTH_REQUEST_STATE_FINISHED:
 			auth_request_unref(&auth_request);
-			hash_table_remove(handler->requests, id);
+			hash_table_remove(handler->requests, key);
 			break;
 		case AUTH_REQUEST_STATE_PASSDB:
 		case AUTH_REQUEST_STATE_USERDB:
@@ -147,7 +145,7 @@
 	   request, so make sure we don't get back here. */
 	timeout_remove(&request->to_abort);
 
-	hash_table_remove(handler->requests, request->id);
+	hash_table_remove(handler->requests, POINTER_CAST(request->id));
 	auth_request_unref(&request);
 }
 
@@ -514,7 +512,7 @@
 		auth_request_unref(&request);
 		return FALSE;
 	}
-	if (hash_table_lookup(handler->requests, id) != NULL) {
+	if (hash_table_lookup(handler->requests, POINTER_CAST(id)) != NULL) {
 		i_error("BUG: Authentication client %u "
 			"sent a duplicate ID %u", handler->client_pid, id);
 		auth_request_unref(&request);
@@ -524,7 +522,7 @@
 
 	request->to_abort = timeout_add(MASTER_AUTH_SERVER_TIMEOUT_SECS * 1000,
 					auth_request_timeout, request);
-	hash_table_insert(handler->requests, id, request);
+	hash_table_insert(handler->requests, POINTER_CAST(id), request);
 
 	if (request->set->ssl_require_client_cert &&
 	    !request->valid_client_cert) {
@@ -579,7 +577,7 @@
 	}
 	data++;
 
-	request = hash_table_lookup(handler->requests, id);
+	request = hash_table_lookup(handler->requests, POINTER_CAST(id));
 	if (request == NULL) {
 		struct auth_stream_reply *reply;
 
@@ -686,7 +684,7 @@
 
 	reply = auth_stream_reply_init(pool_datastack_create());
 
-	request = hash_table_lookup(handler->requests, client_id);
+	request = hash_table_lookup(handler->requests, POINTER_CAST(client_id));
 	if (request == NULL) {
 		i_error("Master request %u.%u not found",
 			handler->client_pid, client_id);
@@ -731,7 +729,7 @@
 {
 	struct auth_request *request;
 
-	request = hash_table_lookup(handler->requests, client_id);
+	request = hash_table_lookup(handler->requests, POINTER_CAST(client_id));
 	if (request != NULL)
 		auth_request_handler_remove(handler, request);
 }
--- a/src/auth/db-checkpassword.c	Mon Aug 20 08:31:00 2012 +0300
+++ b/src/auth/db-checkpassword.c	Mon Aug 20 09:47:28 2012 +0300
@@ -45,7 +45,7 @@
 struct db_checkpassword {
 	char *checkpassword_path, *checkpassword_reply_path;
 
-	HASH_TABLE(pid_t, struct chkpw_auth_request *) clients;
+	HASH_TABLE(void *, struct chkpw_auth_request *) clients;
 	struct child_wait *child_wait;
 };
 
@@ -89,7 +89,8 @@
 	*_request = NULL;
 
 	if (!request->exited) {
-		hash_table_remove(request->db->clients, request->pid);
+		hash_table_remove(request->db->clients,
+				  POINTER_CAST(request->pid));
 		child_wait_remove_pid(request->db->child_wait, request->pid);
 	}
 	checkpassword_request_close(request);
@@ -415,11 +416,11 @@
 			    struct db_checkpassword *db)
 {
 	struct chkpw_auth_request *request = 
-		hash_table_lookup(db->clients, status->pid);
+		hash_table_lookup(db->clients, POINTER_CAST(status->pid));
 
 	i_assert(request != NULL);
 
-	hash_table_remove(db->clients, status->pid);
+	hash_table_remove(db->clients, POINTER_CAST(status->pid));
 	request->exited = TRUE;
 
 	if (WIFSIGNALED(status->status)) {
@@ -531,7 +532,7 @@
 		io_add(fd_out[1], IO_WRITE, checkpassword_child_output,
 		       chkpw_auth_request);
 
-	hash_table_insert(db->clients, pid, chkpw_auth_request);
+	hash_table_insert(db->clients, POINTER_CAST(pid), chkpw_auth_request);
 	child_wait_add_pid(db->child_wait, pid);
 }
 
@@ -554,15 +555,14 @@
 {
 	struct db_checkpassword *db = *_db;
 	struct hash_iterate_context *iter;
-	void *key, *value;
+	void *key;
+	struct chkpw_auth_request *request;
 
 	*_db = NULL;
 
 	iter = hash_table_iterate_init(db->clients);
-	while (hash_table_iterate(iter, &key, &value)) {
-		struct chkpw_auth_request *request = value;
+	while (hash_table_iterate(iter, db->clients, &key, &request))
 		checkpassword_internal_failure(&request);
-	}
 	hash_table_iterate_deinit(&iter);
 
 	child_wait_free(&db->child_wait);
--- a/src/auth/db-ldap.c	Mon Aug 20 08:31:00 2012 +0300
+++ b/src/auth/db-ldap.c	Mon Aug 20 09:47:28 2012 +0300
@@ -1324,7 +1324,7 @@
 	str_append(ctx->debug, "; ");
 
 	iter = hash_table_iterate_init(ctx->ldap_attrs);
-	while (hash_table_iterate_t(iter, ctx->ldap_attrs, &name, &value)) {
+	while (hash_table_iterate(iter, ctx->ldap_attrs, &name, &value)) {
 		if (!value->used) {
 			str_printfa(ctx->debug, "%s,", name);
 			unused_count++;
--- a/src/auth/db-passwd-file.c	Mon Aug 20 08:31:00 2012 +0300
+++ b/src/auth/db-passwd-file.c	Mon Aug 20 09:47:28 2012 +0300
@@ -386,7 +386,7 @@
 		passwd_file_free(db->default_file);
 	else {
 		iter = hash_table_iterate_init(db->files);
-		while (hash_table_iterate_t(iter, db->files, &path, &file))
+		while (hash_table_iterate(iter, db->files, &path, &file))
 			passwd_file_free(file);
 		hash_table_iterate_deinit(&iter);
 		hash_table_destroy(&db->files);
--- a/src/director/director-test.c	Mon Aug 20 08:31:00 2012 +0300
+++ b/src/director/director-test.c	Mon Aug 20 09:47:28 2012 +0300
@@ -548,7 +548,10 @@
 static void main_deinit(void)
 {
 	struct hash_iterate_context *iter;
-	void *key, *value;
+	char *username;
+	struct ip_addr *ip;
+	struct user *user;
+	struct host *host;
 
 	while (imap_clients != NULL) {
 		struct imap_client *client = imap_clients;
@@ -562,18 +565,14 @@
 	}
 
 	iter = hash_table_iterate_init(users);
-	while (hash_table_iterate(iter, &key, &value)) {
-		struct user *user = value;
+	while (hash_table_iterate(iter, users, &username, &user))
 		user_free(user);
-	}
 	hash_table_iterate_deinit(&iter);
 	hash_table_destroy(&users);
 
 	iter = hash_table_iterate_init(hosts);
-	while (hash_table_iterate(iter, &key, &value)) {
-		struct host *host = value;
+	while (hash_table_iterate(iter, hosts, &ip, &host))
 		host_unref(&host);
-	}
 	hash_table_iterate_deinit(&iter);
 	hash_table_destroy(&hosts);
 	array_free(&hosts_array);
--- a/src/director/user-directory.c	Mon Aug 20 08:31:00 2012 +0300
+++ b/src/director/user-directory.c	Mon Aug 20 09:47:28 2012 +0300
@@ -20,8 +20,8 @@
 };
 
 struct user_directory {
-	/* username_hash => user */
-	HASH_TABLE(unsigned int, struct user *) hash;
+	/* unsigned int username_hash => user */
+	HASH_TABLE(void *, struct user *) hash;
 	/* sorted by time */
 	struct user *head, *tail;
 	struct user *prev_insert_pos;
@@ -55,7 +55,7 @@
 
 	user_move_iters(dir, user);
 
-	hash_table_remove(dir->hash, user->username_hash);
+	hash_table_remove(dir->hash, POINTER_CAST(user->username_hash));
 	DLLIST2_REMOVE(&dir->head, &dir->tail, user);
 	i_free(user);
 }
@@ -80,7 +80,7 @@
 {
 	user_directory_drop_expired(dir);
 
-	return hash_table_lookup(dir->hash, username_hash);
+	return hash_table_lookup(dir->hash, POINTER_CAST(username_hash));
 }
 
 static void
@@ -162,7 +162,7 @@
 	}
 
 	dir->prev_insert_pos = user;
-	hash_table_insert(dir->hash, user->username_hash, user);
+	hash_table_insert(dir->hash, POINTER_CAST(user->username_hash), user);
 	return user;
 }
 
--- a/src/doveadm/doveadm-director.c	Mon Aug 20 08:31:00 2012 +0300
+++ b/src/doveadm/doveadm-director.c	Mon Aug 20 09:47:28 2012 +0300
@@ -29,7 +29,7 @@
 	const char *name;
 };
 
-HASH_TABLE_DEFINE_TYPE(user_list, unsigned int, struct user_list *);
+HASH_TABLE_DEFINE_TYPE(user_list, void *, struct user_list *);
 
 extern struct doveadm_cmd doveadm_cmd_director[];
 
@@ -202,10 +202,10 @@
 	user->name = p_strdup(pool, username);
 	user_hash = director_username_hash(username);
 
-	old_user = hash_table_lookup(users, user_hash);
+	old_user = hash_table_lookup(users, POINTER_CAST(user_hash));
 	if (old_user != NULL)
 		user->next = old_user;
-	hash_table_insert(users, user_hash, user);
+	hash_table_insert(users, POINTER_CAST(user_hash), user);
 }
 
 static void ATTR_NULL(1)
@@ -329,7 +329,8 @@
 				doveadm_exit_code = EX_PROTOCOL;
 			} else if (ips_count == 0 ||
 				 ip_find(ips, ips_count, &user_ip)) {
-				user = hash_table_lookup(users, user_hash);
+				user = hash_table_lookup(users,
+							 POINTER_CAST(user_hash));
 				if (user == NULL) {
 					doveadm_print("<unknown>");
 					doveadm_print(args[2]);
--- a/src/doveadm/doveadm-kick.c	Mon Aug 20 08:31:00 2012 +0300
+++ b/src/doveadm/doveadm-kick.c	Mon Aug 20 09:47:28 2012 +0300
@@ -27,7 +27,7 @@
 
 struct kick_context {
 	struct who_context who;
-	HASH_TABLE(pid_t, struct kick_pid *) pids;
+	HASH_TABLE(void *, struct kick_pid *) pids;
 	bool force_kick;
 	ARRAY(const char *) kicked_users;
 };
@@ -42,12 +42,12 @@
 
 	memset(&new_user, 0, sizeof(new_user));
 
-	k_pid = hash_table_lookup(ctx->pids, line->pid);
+	k_pid = hash_table_lookup(ctx->pids, POINTER_CAST(line->pid));
 	if (k_pid == NULL) {
 		k_pid = p_new(ctx->who.pool, struct kick_pid, 1);
 		k_pid->pid = line->pid;
 		p_array_init(&k_pid->users, ctx->who.pool, 5);
-		hash_table_insert(ctx->pids, line->pid, k_pid);
+		hash_table_insert(ctx->pids, POINTER_CAST(line->pid), k_pid);
 	}
 
 	array_foreach_modifiable(&k_pid->users, user) {
@@ -130,15 +130,14 @@
 {
 	bool show_enforce_warning = FALSE;
 	struct hash_iterate_context *iter;
-	void *key, *value;
+	void *key;
+	struct kick_pid *k_pid;
 	const struct kick_user *user;
 
 	p_array_init(&ctx->kicked_users, ctx->who.pool, 10);
 
 	iter = hash_table_iterate_init(ctx->pids);
-	while (hash_table_iterate(iter, &key, &value)) {
-		struct kick_pid *k_pid = value;
-
+	while (hash_table_iterate(iter, ctx->pids, &key, &k_pid)) {
 		if (kick_pid_want_kicked(ctx, k_pid, &show_enforce_warning))
 			k_pid->kick = TRUE;
 	}
@@ -150,9 +149,7 @@
 	}
 
 	iter = hash_table_iterate_init(ctx->pids);
-	while (hash_table_iterate(iter, &key, &value)) {
-		struct kick_pid *k_pid = value;
-
+	while (hash_table_iterate(iter, ctx->pids, &key, &k_pid)) {
 		if (!k_pid->kick)
 			continue;
 
--- a/src/doveadm/doveadm-log.c	Mon Aug 20 08:31:00 2012 +0300
+++ b/src/doveadm/doveadm-log.c	Mon Aug 20 09:47:28 2012 +0300
@@ -174,12 +174,11 @@
 {
 	struct hash_iterate_context *iter;
 	struct stat st;
-	void *key, *value;
+	char *key;
+	struct log_find_file *file;
 
 	iter = hash_table_iterate_init(ctx->files);
-	while (hash_table_iterate(iter, &key, &value)) {
-		struct log_find_file *file = value;
-
+	while (hash_table_iterate(iter, ctx->files, &key, &file)) {
 		if (stat(file->path, &st) < 0 ||
 		    (uoff_t)st.st_size <= file->size)
 			continue;
@@ -260,13 +259,12 @@
 	/* print them */
 	for (i = 0; i < LAST_LOG_TYPE; i++) {
 		struct hash_iterate_context *iter;
-		void *key, *value;
+		char *key;
+		struct log_find_file *file;
 		bool found = FALSE;
 
 		iter = hash_table_iterate_init(ctx.files);
-		while (hash_table_iterate(iter, &key, &value)) {
-			struct log_find_file *file = value;
-
+		while (hash_table_iterate(iter, ctx.files, &key, &file)) {
 			if ((file->mask & (1 << i)) != 0) {
 				printf("%s%s\n", failure_log_type_prefixes[i],
 				       file->path);
--- a/src/doveadm/doveadm-mail-server.c	Mon Aug 20 08:31:00 2012 +0300
+++ b/src/doveadm/doveadm-mail-server.c	Mon Aug 20 09:47:28 2012 +0300
@@ -258,12 +258,11 @@
 {
 	struct hash_iterate_context *iter;
 	struct doveadm_server *ret = NULL;
-	void *key, *value;
+	char *key;
+	struct doveadm_server *server;
 
 	iter = hash_table_iterate_init(servers);
-	while (hash_table_iterate(iter, &key, &value)) {
-		struct doveadm_server *server = value;
-
+	while (hash_table_iterate(iter, servers, &key, &server)) {
 		if (doveadm_server_have_used_connections(server)) {
 			ret = server;
 			break;
@@ -280,7 +279,7 @@
 	struct doveadm_server *server;
 
 	iter = hash_table_iterate_init(servers);
-	while (hash_table_iterate_t(iter, servers, &key, &server)) {
+	while (hash_table_iterate(iter, servers, &key, &server)) {
 		while (array_count(&server->connections) > 0) {
 			struct server_connection *const *connp, *conn;
 
--- a/src/doveadm/doveadm-stats.c	Mon Aug 20 08:31:00 2012 +0300
+++ b/src/doveadm/doveadm-stats.c	Mon Aug 20 09:47:28 2012 +0300
@@ -207,7 +207,7 @@
 	struct top_line *line;
 
 	iter = hash_table_iterate_init(ctx->sessions);
-	while (hash_table_iterate_t(iter, ctx->sessions, &id, &line)) {
+	while (hash_table_iterate(iter, ctx->sessions, &id, &line)) {
 		if (line->flip != ctx->flip)
 			hash_table_remove(ctx->sessions, id);
 	}
--- a/src/doveadm/doveadm-who.c	Mon Aug 20 08:31:00 2012 +0300
+++ b/src/doveadm/doveadm-who.c	Mon Aug 20 09:47:28 2012 +0300
@@ -211,7 +211,7 @@
 static void who_print(struct who_context *ctx)
 {
 	struct hash_iterate_context *iter;
-	void *key, *value;
+	struct who_user *user;
 
 	doveadm_print_header("username", "username", 0);
 	doveadm_print_header("connections", "#",
@@ -221,9 +221,7 @@
 	doveadm_print_header("ips", "(ips)", 0);
 
 	iter = hash_table_iterate_init(ctx->users);
-	while (hash_table_iterate(iter, &key, &value)) {
-		struct who_user *user = value;
-
+	while (hash_table_iterate(iter, ctx->users, &user, &user)) {
 		if (who_user_filter_match(user, &ctx->filter)) T_BEGIN {
 			who_print_user(user);
 		} T_END;
--- a/src/doveadm/dsync/dsync-mailbox-export.c	Mon Aug 20 08:31:00 2012 +0300
+++ b/src/doveadm/dsync/dsync-mailbox-export.c	Mon Aug 20 09:47:28 2012 +0300
@@ -35,8 +35,8 @@
 	ARRAY_TYPE(const_string) expunged_guids;
 	unsigned int expunged_guid_idx;
 
-	/* UID => struct dsync_mail_change */
-	HASH_TABLE(uint32_t, struct dsync_mail_change *) changes;
+	/* uint32_t UID => struct dsync_mail_change */
+	HASH_TABLE(void *, struct dsync_mail_change *) changes;
 	/* changes sorted by UID */
 	ARRAY(struct dsync_mail_change *) sorted_changes;
 	unsigned int change_idx;
@@ -156,7 +156,7 @@
 	const char *guid, *hdr_hash;
 	int ret;
 
-	change = hash_table_lookup(exporter->changes, mail->uid);
+	change = hash_table_lookup(exporter->changes, POINTER_CAST(mail->uid));
 	i_assert(change != NULL);
 	i_assert(change->type == DSYNC_MAIL_CHANGE_TYPE_FLAG_CHANGE);
 
@@ -187,11 +187,11 @@
 {
 	struct dsync_mail_change *change;
 
-	change = hash_table_lookup(exporter->changes, uid);
+	change = hash_table_lookup(exporter->changes, POINTER_CAST(uid));
 	if (change == NULL) {
 		change = p_new(exporter->pool, struct dsync_mail_change, 1);
 		change->uid = uid;
-		hash_table_insert(exporter->changes, uid, change);
+		hash_table_insert(exporter->changes, POINTER_CAST(uid), change);
 	} else {
 		/* move flag changes into a save. this happens only when
 		   last_common_uid isn't known */
@@ -265,12 +265,11 @@
 					 ARRAY_TYPE(seq_range) *uids)
 {
 	struct hash_iterate_context *iter;
-	void *key, *value;
+	void *key;
+	struct dsync_mail_change *change;
 
 	iter = hash_table_iterate_init(exporter->changes);
-	while (hash_table_iterate(iter, &key, &value)) {
-		const struct dsync_mail_change *change = value;
-
+	while (hash_table_iterate(iter, exporter->changes, &key, &change)) {
 		if (change->type == DSYNC_MAIL_CHANGE_TYPE_FLAG_CHANGE)
 			seq_range_array_add(uids, change->uid);
 	}
@@ -281,19 +280,18 @@
 dsync_mailbox_export_drop_expunged_flag_changes(struct dsync_mailbox_exporter *exporter)
 {
 	struct hash_iterate_context *iter;
-	void *key, *value;
+	void *key;
+	struct dsync_mail_change *change;
 
 	/* any flag changes for UIDs above last_common_uid weren't found by
 	   mailbox search, which means they were already expunged. for some
 	   reason the log scanner found flag changes for the message, but not
 	   the expunge. just remove these. */
 	iter = hash_table_iterate_init(exporter->changes);
-	while (hash_table_iterate(iter, &key, &value)) {
-		const struct dsync_mail_change *change = value;
-
+	while (hash_table_iterate(iter, exporter->changes, &key, &change)) {
 		if (change->type == DSYNC_MAIL_CHANGE_TYPE_FLAG_CHANGE &&
 		    change->uid > exporter->last_common_uid)
-			hash_table_remove(exporter->changes, change->uid);
+			hash_table_remove(exporter->changes, key);
 	}
 	hash_table_iterate_deinit(&iter);
 }
@@ -362,16 +360,15 @@
 dsync_mailbox_export_sort_changes(struct dsync_mailbox_exporter *exporter)
 {
 	struct hash_iterate_context *iter;
-	void *key, *value;
+	void *key;
+	struct dsync_mail_change *change;
 
 	p_array_init(&exporter->sorted_changes, exporter->pool,
 		     hash_table_count(exporter->changes));
 
 	iter = hash_table_iterate_init(exporter->changes);
-	while (hash_table_iterate(iter, &key, &value)) {
-		struct dsync_mail_change *change = value;
+	while (hash_table_iterate(iter, exporter->changes, &key, &change))
 		array_append(&exporter->sorted_changes, &change, 1);
-	}
 	hash_table_iterate_deinit(&iter);
 	array_sort(&exporter->sorted_changes, dsync_mail_change_p_uid_cmp);
 }
@@ -382,8 +379,8 @@
 {
 	HASH_TABLE_TYPE(dsync_uid_mail_change) log_changes;
 	struct hash_iterate_context *iter;
-	void *key, *value;
-	struct dsync_mail_change *dup_change;
+	void *key;
+	struct dsync_mail_change *change, *dup_change;
 
 	dsync_transaction_log_scan_get_hash(log_scan, &log_changes);
 	if (dsync_transaction_log_scan_has_all_changes(log_scan))
@@ -393,12 +390,10 @@
 	hash_table_create_direct(&exporter->changes, exporter->pool,
 				 hash_table_count(log_changes));
 	iter = hash_table_iterate_init(log_changes);
-	while (hash_table_iterate(iter, &key, &value)) {
-		const struct dsync_mail_change *change = value;
-
+	while (hash_table_iterate(iter, log_changes, &key, &change)) {
 		dup_change = p_new(exporter->pool, struct dsync_mail_change, 1);
 		*dup_change = *change;
-		hash_table_insert(exporter->changes, change->uid, dup_change);
+		hash_table_insert(exporter->changes, key, dup_change);
 		if (exporter->highest_changed_uid < change->uid)
 			exporter->highest_changed_uid = change->uid;
 	}
@@ -464,7 +459,9 @@
 	struct mail_search_arg *sarg;
 	struct hash_iterate_context *iter;
 	const struct seq_range *uids;
-	void *key, *value;
+	char *guid;
+	const char *const_guid;
+	struct dsync_mail_guid_instances *instances;
 	const struct seq_range *range;
 	unsigned int i, count;
 	uint32_t seq, seq1, seq2;
@@ -478,10 +475,8 @@
 	/* get a list of messages we want to fetch. if there are more than one
 	   instance for a GUID, use the first one. */
 	iter = hash_table_iterate_init(exporter->export_guids);
-	while (hash_table_iterate(iter, &key, &value)) {
-		const char *guid = key;
-		struct dsync_mail_guid_instances *instances = value;
-
+	while (hash_table_iterate(iter, exporter->export_guids,
+				  &guid, &instances)) {
 		if (!instances->requested ||
 		    array_count(&instances->seqs) == 0)
 			continue;
@@ -498,8 +493,9 @@
 			seq_range_array_remove(&exporter->expunged_seqs, seq);
 			if (array_count(&instances->seqs) == 0) {
 				/* no instances left */
+				const_guid = guid;
 				array_append(&exporter->expunged_guids,
-					     &guid, 1);
+					     &const_guid, 1);
 				continue;
 			}
 			uids = array_idx(&instances->seqs, 0);
--- a/src/doveadm/dsync/dsync-mailbox-import.c	Mon Aug 20 08:31:00 2012 +0300
+++ b/src/doveadm/dsync/dsync-mailbox-import.c	Mon Aug 20 09:47:28 2012 +0300
@@ -34,7 +34,7 @@
 };
 
 HASH_TABLE_DEFINE_TYPE(guid_new_mail, const char *, struct importer_new_mail *);
-HASH_TABLE_DEFINE_TYPE(uid_new_mail, uint32_t, struct importer_new_mail *);
+HASH_TABLE_DEFINE_TYPE(uid_new_mail, void *, struct importer_new_mail *);
 
 struct dsync_mailbox_importer {
 	pool_t pool;
@@ -279,11 +279,11 @@
 			return;
 		}
 		first_mail = hash_table_lookup(importer->import_uids,
-					       newmail->uid);
+					       POINTER_CAST(newmail->uid));
 		if (first_mail == NULL) {
 			/* first mail for this UID */
 			hash_table_insert(importer->import_uids,
-					  newmail->uid, newmail);
+					  POINTER_CAST(newmail->uid), newmail);
 			importer_mail_request(importer, newmail);
 			return;
 		}
@@ -656,7 +656,8 @@
 		mail = importer->mail;
 	}
 
-	local_change = hash_table_lookup(importer->local_changes, change->uid);
+	local_change = hash_table_lookup(importer->local_changes,
+					 POINTER_CAST(change->uid));
 	if (local_change == NULL) {
 		local_add = local_remove = 0;
 	} else {
@@ -875,7 +876,8 @@
 	   transaction log and check if the GUIDs match. The GUID in
 	   log is a 128bit GUID, so we may need to convert the remote's
 	   GUID string to 128bit GUID first. */
-	local_change = hash_table_lookup(importer->local_changes, change->uid);
+	local_change = hash_table_lookup(importer->local_changes,
+					 POINTER_CAST(change->uid));
 	if (local_change == NULL || local_change->guid == NULL)
 		return;
 	if (guid_128_from_string(local_change->guid, guid_128) < 0)
@@ -1208,7 +1210,7 @@
 
 	newmail = *mail->guid != '\0' ?
 		hash_table_lookup(importer->import_guids, mail->guid) :
-		hash_table_lookup(importer->import_uids, mail->uid);
+		hash_table_lookup(importer->import_uids, POINTER_CAST(mail->uid));
 	if (newmail == NULL) {
 		if (importer->want_mail_requests) {
 			i_error("%s: Remote sent unwanted message body for "
@@ -1220,8 +1222,10 @@
 	}
 	if (*mail->guid != '\0')
 		hash_table_remove(importer->import_guids, mail->guid);
-	else
-		hash_table_remove(importer->import_uids, mail->uid);
+	else {
+		hash_table_remove(importer->import_uids,
+				  POINTER_CAST(mail->uid));
+	}
 
 	/* save all instances of the message */
 	allmails = newmail;
@@ -1390,7 +1394,7 @@
 	unsigned int msgs_left = 0;
 
 	iter = hash_table_iterate_init(imports);
-	while (hash_table_iterate_t(iter, imports, &key, &mail)) {
+	while (hash_table_iterate(iter, imports, &key, &mail)) {
 		for (; mail != NULL; mail = mail->next) {
 			if (!mail->uid_in_local) {
 				msgs_left++;
@@ -1406,13 +1410,12 @@
 dsync_mailbox_import_count_missing_uid_imports(HASH_TABLE_TYPE(uid_new_mail) imports)
 {
 	struct hash_iterate_context *iter;
-	void *key, *value;
+	void *key;
+	struct importer_new_mail *mail;
 	unsigned int msgs_left = 0;
 
 	iter = hash_table_iterate_init(imports);
-	while (hash_table_iterate(iter, &key, &value)) {
-		struct importer_new_mail *mail = value;
-
+	while (hash_table_iterate(iter, imports, &key, &mail)) {
 		for (; mail != NULL; mail = mail->next) {
 			if (!mail->uid_in_local) {
 				msgs_left++;
--- a/src/doveadm/dsync/dsync-transaction-log-scan.c	Mon Aug 20 08:31:00 2012 +0300
+++ b/src/doveadm/dsync/dsync-transaction-log-scan.c	Mon Aug 20 09:47:28 2012 +0300
@@ -35,13 +35,13 @@
 	if (uid > ctx->highest_wanted_uid)
 		return FALSE;
 
-	change = hash_table_lookup(ctx->changes, uid);
+	change = hash_table_lookup(ctx->changes, POINTER_CAST(uid));
 	if (change == NULL) {
 		/* first change for this UID */
 		change = p_new(ctx->pool, struct dsync_mail_change, 1);
 		change->uid = uid;
 		change->type = type;
-		hash_table_insert(ctx->changes, uid, change);
+		hash_table_insert(ctx->changes, POINTER_CAST(uid), change);
 	} else if (type == DSYNC_MAIL_CHANGE_TYPE_EXPUNGE) {
 		/* expunge overrides flag changes */
 		orig_guid = change->guid;
@@ -454,7 +454,8 @@
 	}
 	mail_transaction_log_view_close(&log_view);
 
-	return !found ? NULL : hash_table_lookup(scan->changes, uid);
+	return !found ? NULL :
+		hash_table_lookup(scan->changes, POINTER_CAST(uid));
 }
 
 void dsync_transaction_log_scan_deinit(struct dsync_transaction_log_scan **_scan)
--- a/src/doveadm/dsync/dsync-transaction-log-scan.h	Mon Aug 20 08:31:00 2012 +0300
+++ b/src/doveadm/dsync/dsync-transaction-log-scan.h	Mon Aug 20 09:47:28 2012 +0300
@@ -2,7 +2,7 @@
 #define DSYNC_TRANSACTION_LOG_SCAN_H
 
 HASH_TABLE_DEFINE_TYPE(dsync_uid_mail_change,
-		       uint32_t, struct dsync_mail_change*);
+		       void *, struct dsync_mail_change *);
 
 struct mail_index_view;
 struct dsync_transaction_log_scan;
--- a/src/imap/imap-client.c	Mon Aug 20 08:31:00 2012 +0300
+++ b/src/imap/imap-client.c	Mon Aug 20 09:47:28 2012 +0300
@@ -155,7 +155,7 @@
 		if (cmd->client->output->closed)
 			i_panic("command didn't cancel itself: %s", cmd->name);
 	} else {
-		client_command_free(_cmd);
+		client_command_free(*_cmd != NULL ? _cmd : &cmd);
 	}
 }
 
--- a/src/lib-auth/auth-server-connection.c	Mon Aug 20 08:31:00 2012 +0300
+++ b/src/lib-auth/auth-server-connection.c	Mon Aug 20 09:47:28 2012 +0300
@@ -144,13 +144,13 @@
 		return -1;
 	}
 
-	request = hash_table_lookup(conn->requests, id);
+	request = hash_table_lookup(conn->requests, POINTER_CAST(id));
 	if (request == NULL) {
 		i_error("BUG: Authentication server sent unknown id %u", id);
 		return -1;
 	}
 	if (remove || auth_client_request_is_aborted(request))
-		hash_table_remove(conn->requests, id);
+		hash_table_remove(conn->requests, POINTER_CAST(id));
 
 	*request_r = request;
 	return 0;
@@ -314,7 +314,8 @@
 {
 	static const char *const temp_failure_args[] = { "temp", NULL };
 	struct hash_iterate_context *iter;
-	void *key, *value;
+	void *key;
+	struct auth_client_request *request;
 	time_t created, oldest = 0;
 	unsigned int request_count = 0;
 
@@ -322,9 +323,7 @@
 		return;
 
 	iter = hash_table_iterate_init(conn->requests);
-	while (hash_table_iterate(iter, &key, &value)) {
-		struct auth_client_request *request = value;
-
+	while (hash_table_iterate(iter, conn->requests, &key, &request)) {
 		if (!auth_client_request_is_aborted(request)) {
 			request_count++;
 			created = auth_client_request_get_create_time(request);
@@ -477,6 +476,6 @@
 		/* wrapped - ID 0 not allowed */
 		id = ++conn->client->request_id_counter;
 	}
-	hash_table_insert(conn->requests, id, request);
+	hash_table_insert(conn->requests, POINTER_CAST(id), request);
 	return id;
 }
--- a/src/lib-auth/auth-server-connection.h	Mon Aug 20 08:31:00 2012 +0300
+++ b/src/lib-auth/auth-server-connection.h	Mon Aug 20 09:47:28 2012 +0300
@@ -19,7 +19,8 @@
 
 	ARRAY(struct auth_mech_desc) available_auth_mechs;
 
-	HASH_TABLE(unsigned int, struct auth_client_request *) requests;
+	/* id => request */
+	HASH_TABLE(void *, struct auth_client_request *) requests;
 
 	unsigned int version_received:1;
 	unsigned int handshake_received:1;
--- a/src/lib-dict/dict-file.c	Mon Aug 20 08:31:00 2012 +0300
+++ b/src/lib-dict/dict-file.c	Mon Aug 20 09:47:28 2012 +0300
@@ -236,7 +236,7 @@
 	const struct file_dict_iterate_path *path;
 	char *key, *value;
 
-	while (hash_table_iterate_t(ctx->iter, dict->hash, &key, &value)) {
+	while (hash_table_iterate(ctx->iter, dict->hash, &key, &value)) {
 		path = file_dict_iterate_find_path(ctx, key);
 		if (path == NULL)
 			continue;
@@ -287,8 +287,8 @@
 	long long diff;
 
 	array_foreach(&ctx->changes, change) {
-		if (hash_table_lookup_full_t(dict->hash, change->key,
-					     &orig_key, &orig_value)) {
+		if (hash_table_lookup_full(dict->hash, change->key,
+					   &orig_key, &orig_value)) {
 			key = orig_key;
 			old_value = orig_value;
 		} else {
@@ -502,7 +502,7 @@
 	output = o_stream_create_fd(fd, 0, FALSE);
 	o_stream_cork(output);
 	iter = hash_table_iterate_init(dict->hash);
-	while (hash_table_iterate_t(iter, dict->hash, &key, &value)) {
+	while (hash_table_iterate(iter, dict->hash, &key, &value)) {
 		o_stream_nsend_str(output, key);
 		o_stream_nsend(output, "\n", 1);
 		o_stream_nsend_str(output, value);
--- a/src/lib-index/mail-cache-fields.c	Mon Aug 20 08:31:00 2012 +0300
+++ b/src/lib-index/mail-cache-fields.c	Mon Aug 20 09:47:28 2012 +0300
@@ -94,18 +94,16 @@
 				struct mail_cache_field *fields,
 				unsigned int fields_count)
 {
-	void *orig_key, *orig_value;
 	char *name;
+	void *value;
 	unsigned int new_idx;
 	unsigned int i, j;
 
 	new_idx = cache->fields_count;
 	for (i = 0; i < fields_count; i++) {
 		if (hash_table_lookup_full(cache->field_name_hash,
-					   fields[i].name,
-					   &orig_key, &orig_value)) {
-			fields[i].idx =
-				POINTER_CAST_TO(orig_value, unsigned int);
+					   fields[i].name, &name, &value)) {
+			fields[i].idx = POINTER_CAST_TO(value, unsigned int);
 			mail_cache_field_update(cache, &fields[i]);
 			continue;
 		}
@@ -151,7 +149,8 @@
 		if (!field_has_fixed_size(cache->fields[idx].field.type))
 			cache->fields[idx].field.field_size = (unsigned int)-1;
 
-		hash_table_insert(cache->field_name_hash, name, idx);
+		hash_table_insert(cache->field_name_hash, name,
+				  POINTER_CAST(idx));
 	}
 	cache->fields_count = new_idx;
 }
@@ -159,11 +158,11 @@
 unsigned int
 mail_cache_register_lookup(struct mail_cache *cache, const char *name)
 {
-	void *orig_key, *orig_value;
+	char *key;
+	void *value;
 
-	if (hash_table_lookup_full(cache->field_name_hash, name,
-				   &orig_key, &orig_value))
-		return POINTER_CAST_TO(orig_value, unsigned int);
+	if (hash_table_lookup_full(cache->field_name_hash, name, &key, &value))
+		return POINTER_CAST_TO(value, unsigned int);
 	else
 		return -1U;
 }
@@ -292,7 +291,8 @@
 	const uint32_t *last_used, *sizes;
 	const uint8_t *types, *decisions;
 	const char *p, *names, *end;
-	void *orig_key, *orig_value;
+	char *orig_key;
+	void *orig_value;
 	unsigned int fidx, new_fields_count;
 	enum mail_cache_decision_type dec;
 	time_t max_drop_time;
--- a/src/lib-index/mail-cache-private.h	Mon Aug 20 08:31:00 2012 +0300
+++ b/src/lib-index/mail-cache-private.h	Mon Aug 20 09:47:28 2012 +0300
@@ -158,7 +158,7 @@
 	struct mail_cache_field_private *fields;
 	uint32_t *field_file_map;
 	unsigned int fields_count;
-	HASH_TABLE(char *, unsigned int) field_name_hash; /* name -> idx */
+	HASH_TABLE(char *, void *) field_name_hash; /* name -> idx */
 	uint32_t last_field_header_offset;
 
 	/* 0 is no need for compression, otherwise the file sequence number
--- a/src/lib-index/mail-index-private.h	Mon Aug 20 08:31:00 2012 +0300
+++ b/src/lib-index/mail-index-private.h	Mon Aug 20 09:47:28 2012 +0300
@@ -215,7 +215,7 @@
 
 	pool_t keywords_pool;
 	ARRAY_TYPE(keywords) keywords;
-	HASH_TABLE(char *, unsigned int) keywords_hash; /* name -> idx */
+	HASH_TABLE(char *, void *) keywords_hash; /* name -> unsigned int idx */
 
 	uint32_t keywords_ext_id;
 	uint32_t modseq_ext_id;
--- a/src/lib-index/mail-index.c	Mon Aug 20 08:31:00 2012 +0300
+++ b/src/lib-index/mail-index.c	Mon Aug 20 09:47:28 2012 +0300
@@ -250,7 +250,8 @@
 bool mail_index_keyword_lookup(struct mail_index *index,
 			       const char *keyword, unsigned int *idx_r)
 {
-	void *key, *value;
+	char *key;
+	void *value;
 
 	/* keywords_hash keeps a name => index mapping of keywords.
 	   Keywords are never removed from it, so the index values are valid
@@ -279,7 +280,8 @@
 	keyword = keyword_dup = p_strdup(index->keywords_pool, keyword);
 	*idx_r = array_count(&index->keywords);
 
-	hash_table_insert(index->keywords_hash, keyword_dup, *idx_r);
+	hash_table_insert(index->keywords_hash, keyword_dup,
+			  POINTER_CAST(*idx_r));
 	array_append(&index->keywords, &keyword, 1);
 
 	/* keep the array NULL-terminated, but the NULL itself invisible */
--- a/src/lib-lda/duplicate.c	Mon Aug 20 08:31:00 2012 +0300
+++ b/src/lib-lda/duplicate.c	Mon Aug 20 09:47:28 2012 +0300
@@ -297,7 +297,7 @@
 
 	memset(&rec, 0, sizeof(rec));
 	iter = hash_table_iterate_init(file->hash);
-	while (hash_table_iterate_t(iter, file->hash, &d, &d)) {
+	while (hash_table_iterate(iter, file->hash, &d, &d)) {
 		rec.stamp = d->time;
 		rec.id_size = d->id_size;
 		rec.user_size = strlen(d->user);
--- a/src/lib-master/master-auth.c	Mon Aug 20 08:31:00 2012 +0300
+++ b/src/lib-master/master-auth.c	Mon Aug 20 09:47:28 2012 +0300
@@ -37,7 +37,7 @@
 	const char *path;
 
 	unsigned int tag_counter;
-	HASH_TABLE(unsigned int, struct master_auth_connection *) connections;
+	HASH_TABLE(void *, struct master_auth_connection *) connections;
 };
 
 struct master_auth *
@@ -63,7 +63,8 @@
 	*_conn = NULL;
 
 	if (conn->tag != 0)
-		hash_table_remove(conn->auth->connections, conn->tag);
+		hash_table_remove(conn->auth->connections,
+				  POINTER_CAST(conn->tag));
 
 	if (conn->callback != NULL)
 		conn->callback(NULL, conn->context);
@@ -84,14 +85,13 @@
 {
 	struct master_auth *auth = *_auth;
 	struct hash_iterate_context *iter;
-	void *key, *value;
+	void *key;
+	struct master_auth_connection *conn;
 
 	*_auth = NULL;
 
 	iter = hash_table_iterate_init(auth->connections);
-	while (hash_table_iterate(iter, &key, &value)) {
-		struct master_auth_connection *conn = value;
-
+	while (hash_table_iterate(iter, auth->connections, &key, &conn)) {
 		conn->tag = 0;
 		master_auth_connection_deinit(&conn);
 	}
@@ -209,7 +209,7 @@
 			       master_auth_connection_timeout, conn);
 	conn->io = io_add(conn->fd, IO_READ,
 			  master_auth_connection_input, conn);
-	hash_table_insert(auth->connections, req.tag, conn);
+	hash_table_insert(auth->connections, POINTER_CAST(req.tag), conn);
 	*tag_r = req.tag;
 }
 
@@ -217,7 +217,7 @@
 {
         struct master_auth_connection *conn;
 
-	conn = hash_table_lookup(auth->connections, tag);
+	conn = hash_table_lookup(auth->connections, POINTER_CAST(tag));
 	if (conn == NULL)
 		i_panic("master_auth_request_abort(): tag %u not found", tag);
 
--- a/src/lib-master/master-login-auth.c	Mon Aug 20 08:31:00 2012 +0300
+++ b/src/lib-master/master-login-auth.c	Mon Aug 20 09:47:28 2012 +0300
@@ -47,7 +47,7 @@
 	struct timeout *to;
 
 	unsigned int id_counter;
-	HASH_TABLE(unsigned int, struct master_login_auth_request *) requests;
+	HASH_TABLE(void *, struct master_login_auth_request *) requests;
 	/* linked list of requests, ordered by create_stamp */
 	struct master_login_auth_request *request_head, *request_tail;
 
@@ -158,7 +158,7 @@
 		request = auth->request_head;
 		DLLIST2_REMOVE(&auth->request_head,
 			       &auth->request_tail, request);
-		hash_table_remove(auth->requests, request->id);
+		hash_table_remove(auth->requests, POINTER_CAST(request->id));
 
 		reason = t_strdup_printf(
 			"Auth server request timed out after %u secs",
@@ -188,7 +188,7 @@
 
 	update_timeout = request->prev == NULL;
 
-	hash_table_remove(auth->requests, request->id);
+	hash_table_remove(auth->requests, POINTER_CAST(request->id));
 	DLLIST2_REMOVE(&auth->request_head, &auth->request_tail, request);
 
 	if (update_timeout) {
@@ -203,7 +203,7 @@
 {
 	struct master_login_auth_request *request;
 
-	request = hash_table_lookup(auth->requests, id);
+	request = hash_table_lookup(auth->requests, POINTER_CAST(id));
 	if (request == NULL) {
 		i_error("Auth server sent reply with unknown ID %u", id);
 		return NULL;
@@ -476,7 +476,7 @@
 	memcpy(login_req->cookie, req->cookie, sizeof(login_req->cookie));
 	login_req->callback = callback;
 	login_req->context = context;
-	hash_table_insert(auth->requests, id, login_req);
+	hash_table_insert(auth->requests, POINTER_CAST(id), login_req);
 	DLLIST2_APPEND(&auth->request_head, &auth->request_tail, login_req);
 
 	if (auth->to == NULL)
--- a/src/lib-settings/settings-parser.c	Mon Aug 20 08:31:00 2012 +0300
+++ b/src/lib-settings/settings-parser.c	Mon Aug 20 09:47:28 2012 +0300
@@ -1781,11 +1781,10 @@
 			  str_hash, strcmp);
 
 	iter = hash_table_iterate_init(old_ctx->links);
-	while (hash_table_iterate_t(iter, old_ctx->links, &key, &value)) {
+	while (hash_table_iterate(iter, old_ctx->links, &key, &value)) {
 		new_link = settings_link_get_new(new_ctx, links, value);
-		hash_table_insert(new_ctx->links,
-				  p_strdup(new_ctx->parser_pool, key),
-				  new_link);
+		key = p_strdup(new_ctx->parser_pool, key);
+		hash_table_insert(new_ctx->links, key, new_link);
 	}
 	hash_table_iterate_deinit(&iter);
 	hash_table_destroy(&links);
--- a/src/lib-storage/index/dbox-multi/mdbox-purge.c	Mon Aug 20 08:31:00 2012 +0300
+++ b/src/lib-storage/index/dbox-multi/mdbox-purge.c	Mon Aug 20 09:47:28 2012 +0300
@@ -43,8 +43,8 @@
 	/* list of file_ids that we need to purge */
 	ARRAY_TYPE(seq_range) purge_file_ids;
 
-	/* map_uid => action */
-	HASH_TABLE(uint32_t, enum mdbox_msg_action) altmoves;
+	/* uint32_t map_uid => enum mdbox_msg_action action */
+	HASH_TABLE(void *, void *) altmoves;
 	bool have_altmoves;
 
 	struct mdbox_map_atomic_context *atomic;
@@ -168,11 +168,13 @@
 mdbox_purge_want_altpath(struct mdbox_purge_context *ctx, uint32_t map_uid)
 {
 	enum mdbox_msg_action action;
+	void *value;
 
 	if (!ctx->have_altmoves)
 		return FALSE;
 
-	action = hash_table_lookup(ctx->altmoves, map_uid);
+	value = hash_table_lookup(ctx->altmoves, POINTER_CAST(map_uid));
+	action = POINTER_CAST_TO(value, enum mdbox_msg_action);
 	return action == MDBOX_MSG_ACTION_MOVE_TO_ALT;
 }
 
@@ -595,7 +597,9 @@
 		    seq_range_exists(&ctx->primary_file_ids, cur_rec.file_id)) {
 			/* all instances marked as moved to alt storage */
 			action = MDBOX_MSG_ACTION_MOVE_TO_ALT;
-			hash_table_insert(ctx->altmoves, cur_map_uid, action);
+			hash_table_insert(ctx->altmoves,
+					  POINTER_CAST(cur_map_uid),
+					  POINTER_CAST(action));
 			seq_range_array_add(&ctx->purge_file_ids,
 					    cur_rec.file_id);
 		}
@@ -627,7 +631,8 @@
 		}
 
 		action = MDBOX_MSG_ACTION_MOVE_FROM_ALT;
-		hash_table_insert(ctx->altmoves, cur_map_uid, action);
+		hash_table_insert(ctx->altmoves, POINTER_CAST(cur_map_uid),
+				  POINTER_CAST(action));
 		seq_range_array_add(&ctx->purge_file_ids, cur_rec.file_id);
 	}
 	ctx->have_altmoves = hash_table_count(ctx->altmoves) > 0;
--- a/src/lib-storage/index/index-thread-finish.c	Mon Aug 20 08:31:00 2012 +0300
+++ b/src/lib-storage/index/index-thread-finish.c	Mon Aug 20 09:47:28 2012 +0300
@@ -78,8 +78,8 @@
 
 	/* (iii) Look up the message associated with the thread
 	   subject in the subject table. */
-	if (!hash_table_lookup_full_t(ctx->subject_hash, subject, &hash_subject,
-				      &hash_node)) {
+	if (!hash_table_lookup_full(ctx->subject_hash, subject, &hash_subject,
+				    &hash_node)) {
 		/* (iv) If there is no message in the subject table with the
 		   thread subject, add the current message and the thread
 		   subject to the subject table. */
--- a/src/lib-storage/index/maildir/maildir-keywords.c	Mon Aug 20 08:31:00 2012 +0300
+++ b/src/lib-storage/index/maildir/maildir-keywords.c	Mon Aug 20 09:47:28 2012 +0300
@@ -32,7 +32,7 @@
 
 	pool_t pool;
 	ARRAY_TYPE(keywords) list;
-	HASH_TABLE(char *, unsigned int) hash; /* name -> idx+1 */
+	HASH_TABLE(char *, void *) hash; /* name -> idx+1 */
 
         struct dotlock_settings dotlock_settings;
 
@@ -176,7 +176,7 @@
 
 		/* save it */
 		new_name = p_strdup(mk->pool, p);
-		hash_table_insert(mk->hash, new_name, idx + 1);
+		hash_table_insert(mk->hash, new_name, POINTER_CAST(idx + 1));
 
 		strp = array_idx_modifiable(&mk->list, idx);
 		*strp = new_name;
@@ -197,10 +197,10 @@
 maildir_keywords_lookup(struct maildir_keywords *mk, const char *name,
 			unsigned int *chridx_r)
 {
-	unsigned int num;
+	void *value;
 
-	num = hash_table_lookup(mk->hash, name);
-	if (num == 0) {
+	value = hash_table_lookup(mk->hash, name);
+	if (value == 0) {
 		if (mk->synced)
 			return 0;
 
@@ -208,12 +208,12 @@
 			return -1;
 		i_assert(mk->synced);
 
-		num = hash_table_lookup(mk->hash, name);
-		if (num == 0)
+		value = hash_table_lookup(mk->hash, name);
+		if (value == 0)
 			return 0;
 	}
 
-	*chridx_r = num-1;
+	*chridx_r = POINTER_CAST_TO(value, unsigned int)-1;
 	return 1;
 }
 
@@ -227,7 +227,7 @@
 	i_assert(chridx < MAILDIR_MAX_KEYWORDS);
 
 	new_name = p_strdup(mk->pool, name);
-	hash_table_insert(mk->hash, new_name, chridx + 1);
+	hash_table_insert(mk->hash, new_name, POINTER_CAST(chridx + 1));
 
 	strp = array_idx_modifiable(&mk->list, chridx);
 	*strp = new_name;
--- a/src/lib-storage/list/mailbox-list-index-sync.c	Mon Aug 20 08:31:00 2012 +0300
+++ b/src/lib-storage/list/mailbox-list-index-sync.c	Mon Aug 20 09:47:28 2012 +0300
@@ -90,8 +90,10 @@
 		node->next = ctx->ilist->mailbox_tree;
 		ctx->ilist->mailbox_tree = node;
 	}
-	hash_table_insert(ctx->ilist->mailbox_hash, node->uid, node);
-	hash_table_insert(ctx->ilist->mailbox_names, node->name_id, dup_name);
+	hash_table_insert(ctx->ilist->mailbox_hash,
+			  POINTER_CAST(node->uid), node);
+	hash_table_insert(ctx->ilist->mailbox_names,
+			  POINTER_CAST(node->name_id), dup_name);
 
 	node_add_to_index(ctx, node, seq_r);
 	return node;
@@ -182,7 +184,8 @@
 	array_foreach(&existing_name_ids, id_p) {
 		if (*id_p != prev_id) {
 			buffer_append(hdr_buf, id_p, sizeof(*id_p));
-			name = hash_table_lookup(ilist->mailbox_names, *id_p);
+			name = hash_table_lookup(ilist->mailbox_names,
+						 POINTER_CAST(*id_p));
 			buffer_append(hdr_buf, name, strlen(name) + 1);
 			prev_id = *id_p;
 		}
--- a/src/lib-storage/list/mailbox-list-index.c	Mon Aug 20 08:31:00 2012 +0300
+++ b/src/lib-storage/list/mailbox-list-index.c	Mon Aug 20 09:47:28 2012 +0300
@@ -111,7 +111,7 @@
 struct mailbox_list_index_node *
 mailbox_list_index_lookup_uid(struct mailbox_list_index *ilist, uint32_t uid)
 {
-	return hash_table_lookup(ilist->mailbox_hash, uid);
+	return hash_table_lookup(ilist->mailbox_hash, POINTER_CAST(uid));
 }
 
 void mailbox_list_index_node_get_path(const struct mailbox_list_index_node *node,
@@ -160,7 +160,7 @@
 		i += len + 1;
 
 		/* add id => name to hash table */
-		hash_table_insert(ilist->mailbox_names, id, name);
+		hash_table_insert(ilist->mailbox_names, POINTER_CAST(id), name);
 		ilist->highest_name_id = id;
 	}
 	i_assert(i == size);
@@ -193,7 +193,7 @@
 
 		node->name_id = irec->name_id;
 		node->name = hash_table_lookup(ilist->mailbox_names,
-					       irec->name_id);
+					       POINTER_CAST(irec->name_id));
 		if (node->name == NULL)
 			return -1;
 
@@ -208,7 +208,8 @@
 			node->next = ilist->mailbox_tree;
 			ilist->mailbox_tree = node;
 		}
-		hash_table_insert(ilist->mailbox_hash, node->uid, node);
+		hash_table_insert(ilist->mailbox_hash,
+				  POINTER_CAST(node->uid), node);
 	}
 	return 0;
 }
--- a/src/lib-storage/list/mailbox-list-index.h	Mon Aug 20 08:31:00 2012 +0300
+++ b/src/lib-storage/list/mailbox-list-index.h	Mon Aug 20 09:47:28 2012 +0300
@@ -93,8 +93,8 @@
 	int iter_refcount;
 
 	pool_t mailbox_pool;
-	/* id => name */
-	HASH_TABLE(uint32_t, char *) mailbox_names;
+	/* uin32_t id => name */
+	HASH_TABLE(void *, char *) mailbox_names;
 	uint32_t highest_name_id;
 
 	uint32_t sync_log_file_seq;
@@ -102,8 +102,8 @@
 	uint32_t sync_stamp;
 	struct timeout *to_refresh;
 
-	/* uid => node */
-	HASH_TABLE(uint32_t, struct mailbox_list_index_node *) mailbox_hash;
+	/* uint32_t uid => node */
+	HASH_TABLE(void *, struct mailbox_list_index_node *) mailbox_hash;
 	struct mailbox_list_index_node *mailbox_tree;
 
 	unsigned int opened:1;
--- a/src/lib/child-wait.c	Mon Aug 20 08:31:00 2012 +0300
+++ b/src/lib/child-wait.c	Mon Aug 20 09:47:28 2012 +0300
@@ -14,7 +14,8 @@
 	void *context;
 };
 
-HASH_TABLE(pid_t, struct child_wait *) child_pids;
+/* pid_t => wait */
+HASH_TABLE(void *, struct child_wait *) child_pids;
 
 #undef child_wait_new_with_pid
 struct child_wait *
@@ -36,18 +37,17 @@
 {
 	struct child_wait *wait = *_wait;
 	struct hash_iterate_context *iter;
-	void *key, *value;
-	pid_t pid;
+	void *key;
+	struct child_wait *value;
 
 	*_wait = NULL;
 
 	if (wait->pid_count > 0) {
 		/* this should be rare, so iterating hash is fast enough */
 		iter = hash_table_iterate_init(child_pids);
-		while (hash_table_iterate(iter, &key, &value)) {
+		while (hash_table_iterate(iter, child_pids, &key, &value)) {
 			if (value == wait) {
-				pid = POINTER_CAST_TO(key, pid_t);
-				hash_table_remove(child_pids, pid);
+				hash_table_remove(child_pids, key);
 				if (--wait->pid_count == 0)
 					break;
 			}
@@ -61,13 +61,13 @@
 void child_wait_add_pid(struct child_wait *wait, pid_t pid)
 {
 	wait->pid_count++;
-	hash_table_insert(child_pids, pid, wait);
+	hash_table_insert(child_pids, POINTER_CAST(pid), wait);
 }
 
 void child_wait_remove_pid(struct child_wait *wait, pid_t pid)
 {
 	wait->pid_count--;
-	hash_table_remove(child_pids, pid);
+	hash_table_remove(child_pids, POINTER_CAST(pid));
 }
 
 static void
@@ -76,7 +76,8 @@
 	struct child_wait_status status;
 
 	while ((status.pid = waitpid(-1, &status.status, WNOHANG)) > 0) {
-		status.wait = hash_table_lookup(child_pids, status.pid);
+		status.wait = hash_table_lookup(child_pids,
+						POINTER_CAST(status.pid));
 		if (status.wait != NULL) {
 			child_wait_remove_pid(status.wait, status.pid);
 			status.wait->callback(&status, status.wait->context);
@@ -98,12 +99,13 @@
 void child_wait_deinit(void)
 {
 	struct hash_iterate_context *iter;
-	void *key, *value;
+	void *key;
+	struct child_wait *value;
 
 	lib_signals_unset_handler(SIGCHLD, sigchld_handler, NULL);
 
 	iter = hash_table_iterate_init(child_pids);
-	while (hash_table_iterate(iter, &key, &value))
+	while (hash_table_iterate(iter, child_pids, &key, &value))
 		i_free(value);
 	hash_table_iterate_deinit(&iter);
 
--- a/src/lib/hash.c	Mon Aug 20 08:31:00 2012 +0300
+++ b/src/lib/hash.c	Mon Aug 20 09:47:28 2012 +0300
@@ -183,9 +183,9 @@
 	return node != NULL ? node->value : NULL;
 }
 
-bool hash_table_lookup_full_i(const struct hash_table *table,
-			      const void *lookup_key,
-			      void **orig_key, void **value)
+bool hash_table_lookup_full(const struct hash_table *table,
+			    const void *lookup_key,
+			    void **orig_key, void **value)
 {
 	struct hash_node *node;
 
--- a/src/lib/hash.h	Mon Aug 20 08:31:00 2012 +0300
+++ b/src/lib/hash.h	Mon Aug 20 09:47:28 2012 +0300
@@ -25,8 +25,8 @@
 #if defined (__GNUC__) && !defined(__cplusplus)
 #  define hash_table_create(table, pool, size, hash_cb, key_cmp_cb) \
 	({(void)COMPILE_ERROR_IF_TRUE( \
-		sizeof((*table)._key) > sizeof(void *) || \
-		sizeof((*table)._value) > sizeof(void *)); \
+		sizeof((*table)._key) != sizeof(void *) || \
+		sizeof((*table)._value) != sizeof(void *)); \
 	(void)COMPILE_ERROR_IF_TRUE( \
 		!__builtin_types_compatible_p(typeof(&key_cmp_cb), \
 			int (*)(typeof((*table)._key), typeof((*table)._key))) && \
@@ -53,8 +53,8 @@
 #if defined (__GNUC__) && !defined(__cplusplus)
 #  define hash_table_create_direct(table, pool, size) \
 	({(void)COMPILE_ERROR_IF_TRUE( \
-		sizeof((*table)._key) > sizeof(void *) || \
-		sizeof((*table)._value) > sizeof(void *)); \
+		sizeof((*table)._key) != sizeof(void *) || \
+		sizeof((*table)._value) != sizeof(void *)); \
 	hash_table_create_direct(&(*table)._table, pool, size);})
 #else
 #  define hash_table_create_direct(table, pool, size) \
@@ -79,20 +79,16 @@
 	HASH_VALUE_CAST(table)hash_table_lookup((table)._table, \
 		(const void *)((const char *)(key) + COMPILE_ERROR_IF_TYPES2_NOT_COMPATIBLE((table)._key, (table)._const_key, key)))
 
-bool hash_table_lookup_full_i(const struct hash_table *table,
-			      const void *lookup_key,
-			      void **orig_key_r, void **value_r);
-/* Type-safe lookup_full requires that key and value types are pointers. */
-#define hash_table_lookup_full_t(table, lookup_key, orig_key_r, value_r) \
-	hash_table_lookup_full_i((table)._table, \
+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_TYPES2_NOT_COMPATIBLE((table)._const_key, (table)._key, lookup_key)), \
 		(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 **)(value_r) + COMPILE_ERROR_IF_TYPES_NOT_COMPATIBLE((table)._valuep, value_r) + \
 			COMPILE_ERROR_IF_TRUE(sizeof(*value_r) != sizeof(void *)))
-/* Type-unsafe lookup_full works for all types. */
-#define hash_table_lookup_full(table, lookup_key, orig_key_r, value_r) \
-	hash_table_lookup_full_i((table)._table, lookup_key, orig_key_r, value_r)
 
 /* Insert/update node in hash table. The difference is that hash_table_insert()
    replaces the key in table to given one, while hash_table_update() doesnt. */
@@ -121,11 +117,9 @@
 struct hash_iterate_context *hash_table_iterate_init(struct hash_table *table);
 #define hash_table_iterate_init(table) \
 	hash_table_iterate_init((table)._table)
-/* Type-unsafe iterate works for all types. */
 bool hash_table_iterate(struct hash_iterate_context *ctx,
 			void **key_r, void **value_r);
-/* Type-safe iterate requires that key and value types are pointers. */
-#define hash_table_iterate_t(ctx, table, key_r, value_r) \
+#define hash_table_iterate(ctx, table, key_r, value_r) \
 	hash_table_iterate(ctx, \
 		(void **)(key_r) + COMPILE_ERROR_IF_TYPES_NOT_COMPATIBLE((table)._keyp, key_r) + \
 			COMPILE_ERROR_IF_TRUE(sizeof(*key_r) != sizeof(void *)) + \
--- a/src/log/log-connection.c	Mon Aug 20 08:31:00 2012 +0300
+++ b/src/log/log-connection.c	Mon Aug 20 09:47:28 2012 +0300
@@ -33,7 +33,7 @@
 	struct istream *input;
 
 	char *default_prefix;
-	HASH_TABLE(pid_t, struct log_client *) clients;
+	HASH_TABLE(void *, struct log_client *) clients;
 
 	unsigned int master:1;
 	unsigned int handshaked:1;
@@ -48,10 +48,10 @@
 {
 	struct log_client *client;
 
-	client = hash_table_lookup(log->clients, pid);
+	client = hash_table_lookup(log->clients, POINTER_CAST(pid));
 	if (client == NULL) {
 		client = i_new(struct log_client, 1);
-		hash_table_insert(log->clients, pid, client);
+		hash_table_insert(log->clients, POINTER_CAST(pid), client);
 	}
 	return client;
 }
@@ -59,7 +59,7 @@
 static void log_client_free(struct log_connection *log,
 			    struct log_client *client, pid_t pid)
 {
-	hash_table_remove(log->clients, pid);
+	hash_table_remove(log->clients, POINTER_CAST(pid));
 
 	i_free(client->prefix);
 	i_free(client);
@@ -163,7 +163,7 @@
 		return;
 	}
 	log = logs[service_fd];
-	client = hash_table_lookup(log->clients, pid);
+	client = hash_table_lookup(log->clients, POINTER_CAST(pid));
 
 	if (strcmp(cmd, "BYE") == 0) {
 		if (client == NULL) {
@@ -211,7 +211,8 @@
 		log_parse_option(log, &failure);
 		return;
 	default:
-		client = hash_table_lookup(log->clients, failure.pid);
+		client = hash_table_lookup(log->clients,
+					   POINTER_CAST(failure.pid));
 		break;
 	}
 	i_assert(failure.log_type < LOG_TYPE_COUNT);
@@ -325,15 +326,16 @@
 static void log_connection_destroy(struct log_connection *log)
 {
 	struct hash_iterate_context *iter;
-	void *key, *value;
+	void *key;
+	struct log_client *client;
 
 	array_idx_clear(&logs_by_fd, log->listen_fd);
 
 	DLLIST_REMOVE(&log_connections, log);
 
 	iter = hash_table_iterate_init(log->clients);
-	while (hash_table_iterate(iter, &key, &value))
-		i_free(value);
+	while (hash_table_iterate(iter, log->clients, &key, &client))
+		i_free(client);
 	hash_table_iterate_deinit(&iter);
 	hash_table_destroy(&log->clients);
 
--- a/src/login-common/ssl-proxy-openssl.c	Mon Aug 20 08:31:00 2012 +0300
+++ b/src/login-common/ssl-proxy-openssl.c	Mon Aug 20 09:47:28 2012 +0300
@@ -1328,7 +1328,7 @@
 		ssl_proxy_destroy(ssl_proxies);
 
 	iter = hash_table_iterate_init(ssl_servers);
-	while (hash_table_iterate_t(iter, ssl_servers, &ctx, &ctx))
+	while (hash_table_iterate(iter, ssl_servers, &ctx, &ctx))
 		ssl_server_context_deinit(&ctx);
 	hash_table_iterate_deinit(&iter);
 	hash_table_destroy(&ssl_servers);
--- a/src/master/service-monitor.c	Mon Aug 20 08:31:00 2012 +0300
+++ b/src/master/service-monitor.c	Mon Aug 20 09:47:28 2012 +0300
@@ -122,7 +122,7 @@
 {
         struct service_process *process;
 
-	process = hash_table_lookup(service_pids, status->pid);
+	process = hash_table_lookup(service_pids, POINTER_CAST(status->pid));
 	if (process == NULL) {
 		/* we've probably wait()ed it away already. ignore */
 		return;
@@ -574,7 +574,7 @@
 	bool service_stopped, throttle;
 
 	while ((pid = waitpid(-1, &status, WNOHANG)) > 0) {
-		process = hash_table_lookup(service_pids, pid);
+		process = hash_table_lookup(service_pids, POINTER_CAST(pid));
 		if (process == NULL) {
 			i_error("waitpid() returned unknown PID %s",
 				dec2str(pid));
--- a/src/master/service-process.c	Mon Aug 20 08:31:00 2012 +0300
+++ b/src/master/service-process.c	Mon Aug 20 09:47:28 2012 +0300
@@ -322,7 +322,7 @@
 	DLLIST_PREPEND(&service->processes, process);
 
 	service_list_ref(service->list);
-	hash_table_insert(service_pids, process->pid, process);
+	hash_table_insert(service_pids, POINTER_CAST(process->pid), process);
 
 	if (service->type == SERVICE_TYPE_ANVIL && process_forked)
 		service_anvil_process_created(process);
@@ -335,7 +335,7 @@
 	struct service_list *service_list = service->list;
 
 	DLLIST_REMOVE(&service->processes, process);
-	hash_table_remove(service_pids, process->pid);
+	hash_table_remove(service_pids, POINTER_CAST(process->pid));
 
 	if (process->available_count > 0)
 		service->process_avail--;
--- a/src/master/service.c	Mon Aug 20 08:31:00 2012 +0300
+++ b/src/master/service.c	Mon Aug 20 09:47:28 2012 +0300
@@ -717,12 +717,13 @@
 void service_pids_deinit(void)
 {
 	struct hash_iterate_context *iter;
-	void *key, *value;
+	void *key;
+	struct service_process *process;
 
 	/* free all child process information */
 	iter = hash_table_iterate_init(service_pids);
-	while (hash_table_iterate(iter, &key, &value))
-		service_process_destroy(value);
+	while (hash_table_iterate(iter, service_pids, &key, &process))
+		service_process_destroy(process);
 	hash_table_iterate_deinit(&iter);
 	hash_table_destroy(&service_pids);
 }
--- a/src/master/service.h	Mon Aug 20 08:31:00 2012 +0300
+++ b/src/master/service.h	Mon Aug 20 09:47:28 2012 +0300
@@ -142,7 +142,7 @@
 	unsigned int sigterm_sent_to_log:1;
 };
 
-HASH_TABLE_DEFINE_TYPE(pid_process, pid_t, struct service_process *);
+HASH_TABLE_DEFINE_TYPE(pid_process, void *, struct service_process *);
 extern HASH_TABLE_TYPE(pid_process) service_pids;
 
 /* Create all services from settings */
--- a/src/plugins/acl/acl-cache.c	Mon Aug 20 08:31:00 2012 +0300
+++ b/src/plugins/acl/acl-cache.c	Mon Aug 20 09:47:28 2012 +0300
@@ -33,7 +33,7 @@
 	/* idx => right name. */
 	ARRAY(const char *) right_idx_name_map;
 	/* name => idx+1 */
-	HASH_TABLE(char *, unsigned int) right_name_idx_map;
+	HASH_TABLE(char *, void *) right_name_idx_map;
 };
 
 static struct acl_mask negative_cache_entry;
@@ -142,21 +142,23 @@
 unsigned int acl_cache_right_lookup(struct acl_cache *cache, const char *right)
 {
 	unsigned int idx;
+	void *idx_p;
 	char *name;
 	const char *const_name;
 
 	/* use +1 for right_name_idx_map values because we can't add NULL
 	   values. */
-	idx = hash_table_lookup(cache->right_name_idx_map, right);
-	if (idx == 0) {
+	idx_p = hash_table_lookup(cache->right_name_idx_map, right);
+	if (idx_p == NULL) {
 		/* new right name, add it */
 		const_name = name = p_strdup(cache->right_names_pool, right);
 
 		idx = array_count(&cache->right_idx_name_map);
 		array_append(&cache->right_idx_name_map, &const_name, 1);
-		hash_table_insert(cache->right_name_idx_map, name, idx + 1);
+		hash_table_insert(cache->right_name_idx_map, name,
+				  POINTER_CAST(idx + 1));
 	} else {
-		idx--;
+		idx = POINTER_CAST_TO(idx_p, unsigned int)-1;
 	}
 	return idx;
 }
@@ -179,7 +181,7 @@
 	struct acl_object_cache *obj_cache;
 
 	iter = hash_table_iterate_init(cache->objects);
-	while (hash_table_iterate_t(iter, cache->objects, &key, &obj_cache))
+	while (hash_table_iterate(iter, cache->objects, &key, &obj_cache))
 		acl_cache_free_object_cache(obj_cache);
 	hash_table_iterate_deinit(&iter);
 
--- a/src/plugins/expire/doveadm-expire.c	Mon Aug 20 08:31:00 2012 +0300
+++ b/src/plugins/expire/doveadm-expire.c	Mon Aug 20 09:47:28 2012 +0300
@@ -33,7 +33,8 @@
 	struct dict_transaction_context *trans;
 	struct dict_iterate_context *iter;
 
-	HASH_TABLE(char *, enum expire_user_state) user_states;
+	/* username => enum expire_user_state */
+	HASH_TABLE(char *, void *) user_states;
 	ARRAY(struct expire_query) queries;
 	time_t oldest_before_time;
 	bool delete_nonexistent_users;
@@ -78,8 +79,8 @@
 		DOVEADM_EXPIRE_MAIL_CMD_CONTEXT(ctx);
 	const char *username, *mailbox;
 	enum expire_user_state state;
-	void *key, *value;
 	char *orig_username;
+	void *value;
 
 	/* dict_key = DICT_EXPIRE_PREFIX<user>/<mailbox> */
 	username = dict_key + strlen(DICT_EXPIRE_PREFIX);
@@ -92,7 +93,7 @@
 	username = t_strdup_until(username, mailbox++);
 
 	if (!hash_table_lookup_full(ectx->user_states, username,
-				    &key, &value)) {
+				    &orig_username, &value)) {
 		/* user no longer exists, delete the record */
 		return -1;
 	}
@@ -113,8 +114,8 @@
 		return 0;
 	}
 	state = EXPIRE_USER_STATE_SEEN;
-	orig_username = key;
-	hash_table_update(ectx->user_states, orig_username, state);
+	hash_table_update(ectx->user_states, orig_username,
+			  POINTER_CAST(state));
 	*username_r = orig_username;
 	return 1;
 }
@@ -424,7 +425,8 @@
 	while (mail_storage_service_all_next(ctx->storage_service, &username) > 0) {
 		username_dup = p_strdup(ctx->pool, username);
 		state = EXPIRE_USER_STATE_EXISTS;
-		hash_table_insert(ectx->user_states, username_dup, state);
+		hash_table_insert(ectx->user_states, username_dup,
+				  POINTER_CAST(state));
 	}
 
 	ectx->dict = dict;
--- a/src/plugins/fts-lucene/lucene-wrapper.cc	Mon Aug 20 08:31:00 2012 +0300
+++ b/src/plugins/fts-lucene/lucene-wrapper.cc	Mon Aug 20 09:47:28 2012 +0300
@@ -1314,7 +1314,7 @@
 	wchar_t *key;
 	struct fts_result *value;
 	iter = hash_table_iterate_init(guids);
-	while (hash_table_iterate_t(iter, guids, &key, &value)) {
+	while (hash_table_iterate(iter, guids, &key, &value)) {
 		Term *term = _CLNEW Term(_T("box"), key);
 		TermQuery *q = _CLNEW TermQuery(term);
 		mailbox_query.add(q, true, BooleanClause::SHOULD);
--- a/src/plugins/fts/fts-expunge-log.c	Mon Aug 20 08:31:00 2012 +0300
+++ b/src/plugins/fts/fts-expunge-log.c	Mon Aug 20 09:47:28 2012 +0300
@@ -231,7 +231,7 @@
 	size_t rec_offset;
 
 	iter = hash_table_iterate_init(ctx->mailboxes);
-	while (hash_table_iterate_t(iter, ctx->mailboxes, &guid_p, &mailbox)) {
+	while (hash_table_iterate(iter, ctx->mailboxes, &guid_p, &mailbox)) {
 		rec_offset = output->used;
 		rec = buffer_append_space_unsafe(output, sizeof(*rec));
 		memcpy(rec->guid, mailbox->guid, sizeof(rec->guid));
--- a/src/pop3/pop3-commands.c	Mon Aug 20 08:31:00 2012 +0300
+++ b/src/pop3/pop3-commands.c	Mon Aug 20 09:47:28 2012 +0300
@@ -711,21 +711,19 @@
         (void)list_uids_iter(client, ctx);
 }
 
-HASH_TABLE_DEFINE_TYPE(uidl_counter, char *, unsigned int);
+HASH_TABLE_DEFINE_TYPE(uidl_counter, char *, void *);
 
 static void
 uidl_rename_duplicate(string_t *uidl, HASH_TABLE_TYPE(uidl_counter) prev_uidls)
 {
-	void *orig_key, *orig_value;
 	char *key;
+	void *value;
 	unsigned int counter;
 
-	while (hash_table_lookup_full(prev_uidls, str_c(uidl),
-				      &orig_key, &orig_value)) {
+	while (hash_table_lookup_full(prev_uidls, str_c(uidl), &key, &value)) {
 		/* duplicate. the value contains the number of duplicates. */
-		key = orig_key;
-		counter = POINTER_CAST_TO(orig_value, unsigned int) + 1;
-		hash_table_update(prev_uidls, key, counter);
+		counter = POINTER_CAST_TO(value, unsigned int) + 1;
+		hash_table_update(prev_uidls, key, POINTER_CAST(counter));
 		str_printfa(uidl, "-%u", counter);
 		/* the second lookup really should return NULL, but just in
 		   case of some weird UIDLs do this as many times as needed */
@@ -777,7 +775,7 @@
 			uidl_rename_duplicate(str, prev_uidls);
 		uidl = p_strdup(client->uidl_pool, str_c(str));
 		client->message_uidls[msgnum] = uidl;
-		hash_table_insert(prev_uidls, uidl, 1U);
+		hash_table_insert(prev_uidls, uidl, POINTER_CAST(1));
 		msgnum++;
 	}
 	(void)mailbox_search_deinit(&search_ctx);
--- a/src/replication/aggregator/replicator-connection.c	Mon Aug 20 08:31:00 2012 +0300
+++ b/src/replication/aggregator/replicator-connection.c	Mon Aug 20 09:47:28 2012 +0300
@@ -29,7 +29,7 @@
 
 	buffer_t *queue[REPLICATION_PRIORITY_SYNC + 1];
 
-	HASH_TABLE(unsigned int, void *) requests;
+	HASH_TABLE(void *, void *) requests;
 	unsigned int request_id_counter;
 	replicator_sync_callback_t *callback;
 };
@@ -49,12 +49,12 @@
 		return -1;
 	}
 
-	context = hash_table_lookup(conn->requests, id);
+	context = hash_table_lookup(conn->requests, POINTER_CAST(id));
 	if (context == NULL) {
 		i_error("Replicator sent invalid ID: %u", id);
 		return -1;
 	}
-	hash_table_remove(conn->requests, id);
+	hash_table_remove(conn->requests, POINTER_CAST(id));
 	conn->callback(line[0] == '+', context);
 	return 0;
 }
@@ -183,7 +183,7 @@
 	void *key, *value;
 
 	iter = hash_table_iterate_init(conn->requests);
-	while (hash_table_iterate(iter, &key, &value))
+	while (hash_table_iterate(iter, conn->requests, &key, &value))
 		conn->callback(FALSE, value);
 	hash_table_iterate_deinit(&iter);
 	hash_table_clear(conn->requests, TRUE);
@@ -316,7 +316,7 @@
 
 	id = ++conn->request_id_counter;
 	if (id == 0) id++;
-	hash_table_insert(conn->requests, id, context);
+	hash_table_insert(conn->requests, POINTER_CAST(id), context);
 
 	T_BEGIN {
 		replicator_send(conn, REPLICATION_PRIORITY_SYNC, t_strdup_printf(