diff options
author | neal <neal> | 2008-02-20 10:03:03 +0000 |
---|---|---|
committer | neal <neal> | 2008-02-20 10:03:03 +0000 |
commit | a0e06d47106a32ffc1f922c6ab39174152c09a9f (patch) | |
tree | be91eb51a1e76f323da8550882f1aa53ad8b2004 /libhurd-ihash | |
parent | f8e526469303a689213fb3a793902b862cf0488b (diff) |
2008-02-20 Neal H. Walfield <neal@gnu.org>
* ihash.c (hurd_ihash_init_with_buffer): Set size to the largest
size in IHASH_SIZES that is less than or equal to the maximum size
that the provided buffer can handle.
Diffstat (limited to 'libhurd-ihash')
-rw-r--r-- | libhurd-ihash/ChangeLog | 6 | ||||
-rw-r--r-- | libhurd-ihash/ihash.c | 9 |
2 files changed, 14 insertions, 1 deletions
diff --git a/libhurd-ihash/ChangeLog b/libhurd-ihash/ChangeLog index 611f30a..3f2af53 100644 --- a/libhurd-ihash/ChangeLog +++ b/libhurd-ihash/ChangeLog @@ -1,3 +1,9 @@ +2008-02-20 Neal H. Walfield <neal@gnu.org> + + * ihash.c (hurd_ihash_init_with_buffer): Set size to the largest + size in IHASH_SIZES that is less than or equal to the maximum size + that the provided buffer can handle. + 2008-02-11 Neal H. Walfield <neal@gnu.org> * t-ihash.c (program_name): Change type to char *. diff --git a/libhurd-ihash/ihash.c b/libhurd-ihash/ihash.c index 4ba9aaf..c34ec74 100644 --- a/libhurd-ihash/ihash.c +++ b/libhurd-ihash/ihash.c @@ -214,7 +214,14 @@ hurd_ihash_init_with_buffer (hurd_ihash_t ht, bool large, { hurd_ihash_init_internal (ht, large, locp_offs); ht->items = buffer; - ht->size = size / ITEM_SIZE (_HURD_IHASH_LARGE (ht)); + + int max_size = size / ITEM_SIZE (_HURD_IHASH_LARGE (ht)); + + int i; + for (i = 0; i < ihash_nsizes; i ++) + if (ihash_sizes[i] > max_size) + break; + ht->size = ihash_sizes[i - 1]; } |