From 202bd8e4d0a4b7e3d09f0eb5a6ac512ff83d9285 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Tue, 8 Dec 2009 11:06:42 -0500 Subject: Change dhash API to be talloc-friendly --- server/util/find_uid.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) (limited to 'server') diff --git a/server/util/find_uid.c b/server/util/find_uid.c index 626d37f6f..09c47b3d8 100644 --- a/server/util/find_uid.c +++ b/server/util/find_uid.c @@ -43,23 +43,12 @@ #define PATHLEN (NAME_MAX + 14) #define BUFSIZE 4096 -TALLOC_CTX *hash_talloc_ctx(TALLOC_CTX *mem_ctx) +static void *hash_talloc(const size_t size, void *pvt) { - static TALLOC_CTX * saved_ctx = NULL; - - if (mem_ctx != NULL) { - saved_ctx = mem_ctx; - } - - return saved_ctx; -} - -void *hash_talloc(const size_t size) -{ - return talloc_size(hash_talloc_ctx(NULL), size); + return talloc_size(pvt, size); } -void hash_talloc_free(void *ptr) +static void hash_talloc_free(void *ptr, void *pvt) { talloc_free(ptr); } @@ -273,9 +262,8 @@ errno_t get_uid_table(TALLOC_CTX *mem_ctx, hash_table_t **table) #ifdef __linux__ int ret; - hash_talloc_ctx(mem_ctx); ret = hash_create_ex(INITIAL_TABLE_SIZE, table, 0, 0, 0, 0, - hash_talloc, hash_talloc_free, NULL); + hash_talloc, hash_talloc_free, mem_ctx, NULL); if (ret != HASH_SUCCESS) { DEBUG(1, ("hash_create_ex failed [%s]\n", hash_error_string(ret))); return ENOMEM; -- cgit