From 49353a00223b95a49f5750d3dcf1501a3f17c4c2 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Sun, 1 Jun 2008 19:08:51 +0200 Subject: [PATCH] Implement --hash-table-bits. --- adu.c | 10 +++++----- adu.ggo | 15 +++++++++++++++ adu.h | 2 +- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/adu.c b/adu.c index 3fca7a0..c21df0b 100644 --- a/adu.c +++ b/adu.c @@ -285,15 +285,15 @@ err: return ret; } -#define uid_hash_bits 8 -uint32_t uid_hash_table_size = 1 << uid_hash_bits; #define PRIME1 0x811c9dc5 #define PRIME2 0x01000193 -void create_hash_table(void) +uint32_t uid_hash_table_size; +void create_hash_table(unsigned bits) { - uid_hash_table = adu_calloc(uid_hash_table_size - * sizeof(struct user_info)); + uid_hash_table_size = 1 << bits; + uid_hash_table = adu_calloc(uid_hash_table_size * + sizeof(struct user_info)); } static void free_hash_table(void) diff --git a/adu.ggo b/adu.ggo index 9f8b710..f2d14c9 100644 --- a/adu.ggo +++ b/adu.ggo @@ -144,6 +144,21 @@ details=" one that the argument being processed is on. " +option "hash-table-bits" - +#~~~~~~~~~~~~~~~~~~~~~~~~~ +"specify the size of the uid hash table" +int typestr="num" +dependon="create" +default="10" +optional +details=" + Use a hash table of size 2^num for the uid entries. If more than + 2^num different uids own at least one regular file under base-dir, + the command fails. Increase this value if you have more than 1024 + users. Decreasing the value causes adu to use slightly less memory. +" + + ############################## section "Options for --select" ############################## diff --git a/adu.h b/adu.h index ea660dd..3e06c95 100644 --- a/adu.h +++ b/adu.h @@ -192,7 +192,7 @@ int open_dir_table(int create); void check_signals(void); void close_all_tables(void); char *get_uid_list_name(void); -void create_hash_table(void); +void create_hash_table(unsigned bits); int search_uid(uint32_t uid, enum search_uid_flags flags, struct user_info **ui_ptr); -- 2.39.5