dovecot-1.2: Renamed hash_*() to hash_table_*() to avoid conflic...

dovecot at dovecot.org dovecot at dovecot.org
Fri Dec 19 09:06:43 EET 2008


details:   http://hg.dovecot.org/dovecot-1.2/rev/f9166a09423a
changeset: 8573:f9166a09423a
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Dec 19 09:06:38 2008 +0200
description:
Renamed hash_*() to hash_table_*() to avoid conflicts with OSX's strhash.h
Based on patch by Apple.

diffstat:

31 files changed, 385 insertions(+), 363 deletions(-)
src/auth/auth-cache.c                            |   18 +-
src/auth/auth-request-handler.c                  |   24 +--
src/auth/db-ldap.c                               |   14 -
src/auth/db-passwd-file.c                        |   34 ++--
src/auth/otp-skey-common.c                       |   12 -
src/auth/passdb-checkpassword.c                  |   17 +-
src/auth/passdb-ldap.c                           |    4 
src/auth/userdb-checkpassword.c                  |   17 +-
src/auth/userdb-ldap.c                           |    4 
src/deliver/duplicate.c                          |   21 +-
src/lib-auth/auth-server-connection.c            |    4 
src/lib-auth/auth-server-request.c               |   38 ++---
src/lib-dict/dict-file.c                         |   32 ++--
src/lib-index/mail-cache-fields.c                |   16 +-
src/lib-index/mail-cache.c                       |    6 
src/lib-index/mail-index.c                       |   12 -
src/lib-sql/sql-pool.c                           |   10 -
src/lib-storage/index/dbox/dbox-sync.c           |   14 -
src/lib-storage/index/index-thread-finish.c      |   13 -
src/lib-storage/index/maildir/maildir-keywords.c |   16 +-
src/lib-storage/index/maildir/maildir-uidlist.c  |   44 +++---
src/lib/child-wait.c                             |   26 +--
src/lib/hash.c                                   |  161 +++++++++++-----------
src/lib/hash.h                                   |   46 +++---
src/login-common/master.c                        |   16 +-
src/login-common/ssl-proxy-gnutls.c              |   15 +-
src/master/auth-process.c                        |   26 +--
src/master/child-process.c                       |   12 -
src/master/login-process.c                       |   12 -
src/master/mail-process.c                        |   24 +--
src/plugins/acl/acl-cache.c                      |   40 ++---

diffs (truncated from 2297 to 300 lines):

diff -r 9ec2882243a6 -r f9166a09423a src/auth/auth-cache.c
--- a/src/auth/auth-cache.c	Fri Dec 19 08:50:14 2008 +0200
+++ b/src/auth/auth-cache.c	Fri Dec 19 09:06:38 2008 +0200
@@ -86,7 +86,7 @@ auth_cache_node_destroy(struct auth_cach
 	auth_cache_node_unlink(cache, node);
 
 	cache->size_left += node->alloc_size;
-	hash_remove(cache->hash, node->data);
+	hash_table_remove(cache->hash, node->data);
 	i_free(node);
 }
 
@@ -119,8 +119,8 @@ struct auth_cache *auth_cache_new(size_t
 	struct auth_cache *cache;
 
 	cache = i_new(struct auth_cache, 1);
-	cache->hash = hash_create(default_pool, default_pool, 0, str_hash,
-				  (hash_cmp_callback_t *)strcmp);
+	cache->hash = hash_table_create(default_pool, default_pool, 0, str_hash,
+					(hash_cmp_callback_t *)strcmp);
 	cache->size_left = max_size;
 	cache->ttl_secs = ttl_secs;
 	cache->neg_ttl_secs = neg_ttl_secs;
@@ -139,7 +139,7 @@ void auth_cache_free(struct auth_cache *
 	lib_signals_unset_handler(SIGUSR2, sig_auth_cache_stats, cache);
 
 	auth_cache_clear(cache);
-	hash_destroy(&cache->hash);
+	hash_table_destroy(&cache->hash);
 	i_free(cache);
 }
 
@@ -147,7 +147,7 @@ void auth_cache_clear(struct auth_cache 
 {
 	while (cache->tail != NULL)
 		auth_cache_node_destroy(cache, cache->tail);
-	hash_clear(cache->hash, FALSE);
+	hash_table_clear(cache->hash, FALSE);
 }
 
 const char *
@@ -169,7 +169,7 @@ auth_cache_lookup(struct auth_cache *cac
 		   auth_request_get_var_expand_table(request,
 						     auth_request_str_escape));
 
-	node = hash_lookup(cache->hash, str_c(str));
+	node = hash_table_lookup(cache->hash, str_c(str));
 	if (node == NULL) {
 		cache->miss_count++;
 		return NULL;
@@ -233,7 +233,7 @@ void auth_cache_insert(struct auth_cache
 	while (cache->size_left < alloc_size)
 		auth_cache_node_destroy(cache, cache->tail);
 
-	node = hash_lookup(cache->hash, str_c(str));
+	node = hash_table_lookup(cache->hash, str_c(str));
 	if (node != NULL) {
 		/* key is already in cache (probably expired), remove it */
 		auth_cache_node_destroy(cache, node);
@@ -250,7 +250,7 @@ void auth_cache_insert(struct auth_cache
 	auth_cache_node_link_head(cache, node);
 
 	cache->size_left -= alloc_size;
-	hash_insert(cache->hash, node->data, node);
+	hash_table_insert(cache->hash, node->data, node);
 }
 
 void auth_cache_remove(struct auth_cache *cache,
@@ -265,7 +265,7 @@ void auth_cache_remove(struct auth_cache
 		   auth_request_get_var_expand_table(request,
 		   				     auth_request_str_escape));
 
-	node = hash_lookup(cache->hash, str_c(str));
+	node = hash_table_lookup(cache->hash, str_c(str));
 	if (node == NULL)
 		return;
 
diff -r 9ec2882243a6 -r f9166a09423a src/auth/auth-request-handler.c
--- a/src/auth/auth-request-handler.c	Fri Dec 19 08:50:14 2008 +0200
+++ b/src/auth/auth-request-handler.c	Fri Dec 19 09:06:38 2008 +0200
@@ -52,7 +52,7 @@ auth_request_handler_create(struct auth 
 	handler = p_new(pool, struct auth_request_handler, 1);
 	handler->refcount = 1;
 	handler->pool = pool;
-	handler->requests = hash_create(default_pool, pool, 0, NULL, NULL);
+	handler->requests = hash_table_create(default_pool, pool, 0, NULL, NULL);
 	handler->auth = auth;
 	handler->callback = callback;
 	handler->context = context;
@@ -71,18 +71,18 @@ void auth_request_handler_unref(struct a
 	if (--handler->refcount > 0)
 		return;
 
-	iter = hash_iterate_init(handler->requests);
-	while (hash_iterate(iter, &key, &value)) {
+	iter = hash_table_iterate_init(handler->requests);
+	while (hash_table_iterate(iter, &key, &value)) {
 		struct auth_request *auth_request = value;
 
 		auth_request_unref(&auth_request);
 	}
-	hash_iterate_deinit(&iter);
+	hash_table_iterate_deinit(&iter);
 
 	/* notify parent that we're done with all requests */
 	handler->callback(NULL, handler->context);
 
-	hash_destroy(&handler->requests);
+	hash_table_destroy(&handler->requests);
 	pool_unref(&handler->pool);
 }
 
@@ -97,7 +97,7 @@ static void auth_request_handler_remove(
 static void auth_request_handler_remove(struct auth_request_handler *handler,
 					struct auth_request *request)
 {
-	hash_remove(handler->requests, POINTER_CAST(request->id));
+	hash_table_remove(handler->requests, POINTER_CAST(request->id));
 	auth_request_unref(&request);
 }
 
@@ -106,14 +106,14 @@ void auth_request_handler_check_timeouts
 	struct hash_iterate_context *iter;
 	void *key, *value;
 
-	iter = hash_iterate_init(handler->requests);
-	while (hash_iterate(iter, &key, &value)) {
+	iter = hash_table_iterate_init(handler->requests);
+	while (hash_table_iterate(iter, &key, &value)) {
 		struct auth_request *request = value;
 
 		if (request->last_access + AUTH_REQUEST_TIMEOUT < ioloop_time)
 			auth_request_handler_remove(handler, request);
 	}
-	hash_iterate_deinit(&iter);
+	hash_table_iterate_deinit(&iter);
 }
 
 static void get_client_extra_fields(struct auth_request *request,
@@ -352,7 +352,7 @@ bool auth_request_handler_auth_begin(str
 		return FALSE;
 	}
 
-	hash_insert(handler->requests, POINTER_CAST(id), request);
+	hash_table_insert(handler->requests, POINTER_CAST(id), request);
 
 	if (request->auth->ssl_require_client_cert &&
 	    !request->valid_client_cert) {
@@ -402,7 +402,7 @@ bool auth_request_handler_auth_continue(
 
 	id = (unsigned int)strtoul(args, NULL, 10);
 
-	request = hash_lookup(handler->requests, POINTER_CAST(id));
+	request = hash_table_lookup(handler->requests, POINTER_CAST(id));
 	if (request == NULL) {
 		struct auth_stream_reply *reply;
 
@@ -489,7 +489,7 @@ void auth_request_handler_master_request
 
 	reply = auth_stream_reply_init(pool_datastack_create());
 
-	request = hash_lookup(handler->requests, POINTER_CAST(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);
diff -r 9ec2882243a6 -r f9166a09423a src/auth/db-ldap.c
--- a/src/auth/db-ldap.c	Fri Dec 19 08:50:14 2008 +0200
+++ b/src/auth/db-ldap.c	Fri Dec 19 09:06:38 2008 +0200
@@ -917,13 +917,13 @@ void db_ldap_set_attrs(struct ldap_conne
 
 		if (*name != '\0' &&
 		    (skip_attr == NULL || strcmp(skip_attr, value) != 0)) {
-			hash_insert(attr_map, name, value);
+			hash_table_insert(attr_map, name, value);
 			(*attr_names_r)[j++] = name;
 		}
 	}
 	if (str_len(static_data) > 0) {
-		hash_insert(attr_map, "",
-			    p_strdup(conn->pool, str_c(static_data)));
+		hash_table_insert(attr_map, "",
+				  p_strdup(conn->pool, str_c(static_data)));
 	}
 }
 
@@ -986,7 +986,7 @@ db_ldap_result_iterate_init(struct ldap_
 	ctx->auth_request = auth_request;
 	ctx->attr_map = attr_map;
 
-	static_data = hash_lookup(attr_map, "");
+	static_data = hash_table_lookup(attr_map, "");
 	if (static_data != NULL) {
 		const struct var_expand_table *table;
 		string_t *str;
@@ -1023,7 +1023,7 @@ static void
 static void
 db_ldap_result_change_attr(struct db_ldap_result_iterate_context *ctx)
 {
-	ctx->name = hash_lookup(ctx->attr_map, ctx->attr);
+	ctx->name = hash_table_lookup(ctx->attr_map, ctx->attr);
 	ctx->template = NULL;
 
 	if (ctx->debug != NULL) {
@@ -1260,9 +1260,9 @@ void db_ldap_unref(struct ldap_connectio
 	aqueue_deinit(&conn->request_queue);
 
 	if (conn->pass_attr_map != NULL)
-		hash_destroy(&conn->pass_attr_map);
+		hash_table_destroy(&conn->pass_attr_map);
 	if (conn->user_attr_map != NULL)
-		hash_destroy(&conn->user_attr_map);
+		hash_table_destroy(&conn->user_attr_map);
 	pool_unref(&conn->pool);
 }
 
diff -r 9ec2882243a6 -r f9166a09423a src/auth/db-passwd-file.c
--- a/src/auth/db-passwd-file.c	Fri Dec 19 08:50:14 2008 +0200
+++ b/src/auth/db-passwd-file.c	Fri Dec 19 09:06:38 2008 +0200
@@ -29,7 +29,7 @@ static void passwd_file_add(struct passw
 	char *user;
 	size_t len;
 
-	if (hash_lookup(pw->users, username) != NULL) {
+	if (hash_table_lookup(pw->users, username) != NULL) {
 		i_error("passwd-file %s: User %s exists more than once",
 			pw->path, username);
 		return;
@@ -136,7 +136,7 @@ static void passwd_file_add(struct passw
                         p_strsplit_spaces(pw->pool, extra_fields, " ");
         }
 
-	hash_insert(pw->users, user, pu);
+	hash_table_insert(pw->users, user, pu);
 }
 
 static struct passwd_file *
@@ -150,7 +150,7 @@ passwd_file_new(struct db_passwd_file *d
 	pw->fd = -1;
 
 	if (db->files != NULL)
-		hash_insert(db->files, pw->path, pw);
+		hash_table_insert(db->files, pw->path, pw);
 	return pw;
 }
 
@@ -179,8 +179,8 @@ static bool passwd_file_open(struct pass
 	pw->size = st.st_size;
 
 	pw->pool = pool_alloconly_create(MEMPOOL_GROWING"passwd_file", 10240);
-	pw->users = hash_create(default_pool, pw->pool, 100,
-				str_hash, (hash_cmp_callback_t *)strcmp);
+	pw->users = hash_table_create(default_pool, pw->pool, 100,
+				      str_hash, (hash_cmp_callback_t *)strcmp);
 
 	input = i_stream_create_fd(pw->fd, 4096, FALSE);
 	i_stream_set_return_partial_line(input, TRUE);
@@ -203,7 +203,7 @@ static bool passwd_file_open(struct pass
 
 	if (pw->db->debug) {
 		i_info("passwd-file %s: Read %u users",
-		       pw->path, hash_count(pw->users));
+		       pw->path, hash_table_count(pw->users));
 	}
 	return TRUE;
 }
@@ -217,7 +217,7 @@ static void passwd_file_close(struct pas
 	}
 
 	if (pw->users != NULL)
-		hash_destroy(&pw->users);
+		hash_table_destroy(&pw->users);
 	if (pw->pool != NULL)
 		pool_unref(&pw->pool);
 }
@@ -225,7 +225,7 @@ static void passwd_file_free(struct pass
 static void passwd_file_free(struct passwd_file *pw)
 {
 	if (pw->db->files != NULL)
-		hash_remove(pw->db->files, pw->path);
+		hash_table_remove(pw->db->files, pw->path);
 
 	passwd_file_close(pw);
 	i_free(pw->path);
@@ -309,9 +309,9 @@ db_passwd_file_init(const char *path, co
 
 	db->path = i_strdup(path);
 	if (db->vars) {
-		db->files = hash_create(default_pool, default_pool, 100,
-					str_hash,
-					(hash_cmp_callback_t *)strcmp);
+		db->files = hash_table_create(default_pool, default_pool, 100,
+					      str_hash,
+					      (hash_cmp_callback_t *)strcmp);
 	} else {
 		db->default_file = passwd_file_new(db, path);
 	}
@@ -352,14 +352,14 @@ void db_passwd_file_unref(struct db_pass
 	if (db->default_file != NULL)
 		passwd_file_free(db->default_file);


More information about the dovecot-cvs mailing list