X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Fhtable%2Fhtable.c;h=20b6f5ae2dc964c521aa7f517912cd3d4ab9aa6c;hp=bbd4fa96e587c64a04446756787bd163ad4dc3c8;hb=ab83de953730f5e5e571dbf69ffb3cc685a102dc;hpb=d3104024f71cf4f89195787add6c7ac381d62f40 diff --git a/ccan/htable/htable.c b/ccan/htable/htable.c index bbd4fa96..20b6f5ae 100644 --- a/ccan/htable/htable.c +++ b/ccan/htable/htable.c @@ -1,3 +1,4 @@ +/* Licensed under LGPLv2+ - see LICENSE file for details */ #include #include #include @@ -66,8 +67,8 @@ struct htable *htable_new(size_t (*rehash)(const void *elem, void *priv), ht->priv = priv; ht->elems = 0; ht->deleted = 0; - ht->max = (1 << ht->bits) * 2 / 3; - ht->max_with_deleted = (1 << ht->bits) * 4 / 5; + ht->max = ((size_t)1 << ht->bits) * 3 / 4; + ht->max_with_deleted = ((size_t)1 << ht->bits) * 9 / 10; /* This guarantees we enter update_common first add. */ ht->common_mask = -1; ht->common_bits = 0; @@ -155,7 +156,7 @@ static void ht_add(struct htable *ht, const void *new, size_t h) ht->table[i] = make_hval(ht, new, get_hash_ptr_bits(ht, h)|perfect); } -static COLD_ATTRIBUTE bool double_table(struct htable *ht) +static COLD bool double_table(struct htable *ht) { unsigned int i; size_t oldnum = (size_t)1 << ht->bits; @@ -192,7 +193,7 @@ static COLD_ATTRIBUTE bool double_table(struct htable *ht) return true; } -static COLD_ATTRIBUTE void rehash_table(struct htable *ht) +static COLD void rehash_table(struct htable *ht) { size_t start, i; uintptr_t e; @@ -217,7 +218,7 @@ static COLD_ATTRIBUTE void rehash_table(struct htable *ht) } /* We stole some bits, now we need to put them back... */ -static COLD_ATTRIBUTE void update_common(struct htable *ht, const void *p) +static COLD void update_common(struct htable *ht, const void *p) { unsigned int i; uintptr_t maskdiff, bitsdiff;