hash_offt: standalone hash for curl_off_t

Add a standalong hash table for curl_offt_t as key. This allows a
smaller memory footprint and faster lookups as we do not need to deal
with variable key lengths.

Use in all places we had the standard hash for this purpose.

Closes #16442
This commit is contained in:
Stefan Eissing 2025-02-23 12:20:17 +01:00 committed by Daniel Stenberg
parent 2809723ddf
commit 1aa69221be
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
14 changed files with 392 additions and 110 deletions

View file

@ -400,25 +400,3 @@ Curl_hash_next_element(struct Curl_hash_iterator *iter)
return iter->current;
}
void Curl_hash_offt_init(struct Curl_hash *h,
size_t slots,
Curl_hash_dtor dtor)
{
Curl_hash_init(h, slots, Curl_hash_str, Curl_str_key_compare, dtor);
}
void *Curl_hash_offt_set(struct Curl_hash *h, curl_off_t id, void *elem)
{
return Curl_hash_add(h, &id, sizeof(id), elem);
}
int Curl_hash_offt_remove(struct Curl_hash *h, curl_off_t id)
{
return Curl_hash_delete(h, &id, sizeof(id));
}
void *Curl_hash_offt_get(struct Curl_hash *h, curl_off_t id)
{
return Curl_hash_pick(h, &id, sizeof(id));
}