From: Andre Noll Date: Sun, 1 Jun 2008 17:08:51 +0000 (+0200) Subject: Implement --hash-table-bits. X-Git-Tag: v0.0.2~10 X-Git-Url: http://git.tuebingen.mpg.de/?p=adu.git;a=commitdiff_plain;h=49353a00223b95a49f5750d3dcf1501a3f17c4c2 Implement --hash-table-bits. --- 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);