NetSurf
|
Go to the source code of this file.
Data Structures | |
struct | hashmap_entry_s |
Hashmaps have chains of entries in buckets. More... | |
struct | hashmap_s |
The content of a hashmap. More... | |
Macros | |
#define | DEFAULT_HASHMAP_BUCKETS (4091) |
The default number of buckets in the hashmaps we create. More... | |
Typedefs | |
typedef struct hashmap_entry_s | hashmap_entry_t |
Hashmaps have chains of entries in buckets. More... | |
Functions | |
hashmap_t * | hashmap_create (hashmap_parameters_t *params) |
Create a hashmap. More... | |
void | hashmap_destroy (hashmap_t *hashmap) |
Destroy a hashmap. More... | |
void * | hashmap_lookup (hashmap_t *hashmap, void *key) |
Look up a key in a hashmap. More... | |
void * | hashmap_insert (hashmap_t *hashmap, void *key) |
Create an entry in a hashmap. More... | |
bool | hashmap_remove (hashmap_t *hashmap, void *key) |
Remove an entry from the hashmap. More... | |
bool | hashmap_iterate (hashmap_t *hashmap, hashmap_iteration_cb_t cb, void *ctx) |
Iterate the hashmap. More... | |
size_t | hashmap_count (hashmap_t *hashmap) |
Get the number of entries in this map. More... | |
#define DEFAULT_HASHMAP_BUCKETS (4091) |
typedef struct hashmap_entry_s hashmap_entry_t |
Hashmaps have chains of entries in buckets.
size_t hashmap_count | ( | hashmap_t * | hashmap | ) |
Get the number of entries in this map.
hashmap | The hashmap to retrieve the entry count from |
Definition at line 252 of file hashmap.c.
References hashmap_s::entry_count.
Referenced by store_evict().
hashmap_t * hashmap_create | ( | hashmap_parameters_t * | params | ) |
Create a hashmap.
The provided hashmap parameter table will be used for map operations which need to allocate/free etc.
params | The hashmap parameters for this map |
Definition at line 67 of file hashmap.c.
References hashmap_s::bucket_count, hashmap_s::buckets, DEFAULT_HASHMAP_BUCKETS, hashmap_s::entry_count, and hashmap_s::params.
Referenced by fetch_curl_register(), and read_entries().
void hashmap_destroy | ( | hashmap_t * | hashmap | ) |
Destroy a hashmap.
After this, all keys and values will have been destroyed and all memory associated with this hashmap will be invalidated.
hashmap | The hashmap to destroy |
Definition at line 91 of file hashmap.c.
References hashmap_s::bucket_count, hashmap_s::buckets, hashmap_entry_s::key, hashmap_parameters_t::key_destroy, hashmap_entry_s::next, hashmap_s::params, hashmap_entry_s::value, and hashmap_parameters_t::value_destroy.
Referenced by fetch_curl_finalise(), finalise(), and initialise().
void * hashmap_insert | ( | hashmap_t * | hashmap, |
void * | key | ||
) |
Create an entry in a hashmap.
This creates a blank value using the parameters and then associates it with a clone of the given key, inserting it into the hashmap. If a value was present for the given key already, then it is destroyed first.
NOTE: If allocation of the new value object fails, then any existing entry will be left alone, but NULL will be returned.
hashmap | The hashmap to insert into |
key | The key to insert an entry for |
Definition at line 131 of file hashmap.c.
References hashmap_s::bucket_count, hashmap_s::buckets, hashmap_s::entry_count, hashmap_entry_s::key, hashmap_parameters_t::key_clone, hashmap_parameters_t::key_destroy, hashmap_parameters_t::key_eq, hashmap_entry_s::key_hash, hashmap_parameters_t::key_hash, hashmap_entry_s::next, hashmap_s::params, hashmap_entry_s::prevptr, hashmap_entry_s::value, hashmap_parameters_t::value_alloc, and hashmap_parameters_t::value_destroy.
Referenced by read_entries(), and set_store_entry().
bool hashmap_iterate | ( | hashmap_t * | hashmap, |
hashmap_iteration_cb_t | cb, | ||
void * | ctx | ||
) |
Iterate the hashmap.
For each key/value pair in the hashmap, call the callback passing in the key and value. During iteration you MUST NOT mutate the hashmap.
hashmap | The hashmap to iterate |
cb | The callback for each key,value pair |
ctx | The callback context |
Definition at line 233 of file hashmap.c.
References hashmap_s::bucket_count, hashmap_s::buckets, and hashmap_entry_s::next.
Referenced by store_evict(), and write_entries().
void * hashmap_lookup | ( | hashmap_t * | hashmap, |
void * | key | ||
) |
Look up a key in a hashmap.
If the key has an associated value in the hashmap then the pointer to it is returned, otherwise NULL.
hashmap | The hashmap to look up the key inside |
key | The key to look up in the hashmap |
Definition at line 113 of file hashmap.c.
References hashmap_s::bucket_count, hashmap_s::buckets, hashmap_entry_s::key, hashmap_parameters_t::key_eq, hashmap_entry_s::key_hash, hashmap_parameters_t::key_hash, hashmap_entry_s::next, hashmap_s::params, and hashmap_entry_s::value.
Referenced by fetch_curl_report_certs_upstream(), get_store_entry(), and set_store_entry().
bool hashmap_remove | ( | hashmap_t * | hashmap, |
void * | key | ||
) |
Remove an entry from the hashmap.
This will remove the entry for the given key from the hashmap If there is no such entry, this will safely do nothing. The value associated with the entry will be destroyed and so should not be used beyond calling this function.
hashmap | The hashmap to remove the entry from |
key | The key to remove the entry for |
Definition at line 206 of file hashmap.c.
References hashmap_s::bucket_count, hashmap_s::buckets, hashmap_s::entry_count, hashmap_entry_s::key, hashmap_parameters_t::key_destroy, hashmap_parameters_t::key_eq, hashmap_entry_s::key_hash, hashmap_parameters_t::key_hash, hashmap_entry_s::next, hashmap_s::params, hashmap_entry_s::prevptr, hashmap_entry_s::value, and hashmap_parameters_t::value_destroy.
Referenced by invalidate_entry().