Tor 0.4.9.0-alpha-dev
|
Hash-table implementations of a string-to-void* map, and of a digest-to-void* map. More...
#include "lib/container/map.h"
#include "lib/ctime/di_ops.h"
#include "lib/defs/digest_sizes.h"
#include "lib/string/util_string.h"
#include "lib/malloc/malloc.h"
#include "lib/log/util_bug.h"
#include <stdlib.h>
#include <string.h>
#include "ext/ht.h"
Go to the source code of this file.
Macros | |
#define | DEFINE_MAP_STRUCTS(maptype, keydecl, prefix) |
#define | strmap_entry_free(ent) FREE_AND_NULL(strmap_entry_t, strmap_entry_free_, (ent)) |
#define | digestmap_entry_free(ent) FREE_AND_NULL(digestmap_entry_t, digestmap_entry_free_, (ent)) |
#define | digest256map_entry_free(ent) FREE_AND_NULL(digest256map_entry_t, digest256map_entry_free_, (ent)) |
#define | IMPLEMENT_MAP_FNS(maptype, keytype, prefix) |
Functions | |
DEFINE_MAP_STRUCTS (strmap_t, char *key, strmap_) | |
DEFINE_MAP_STRUCTS (digestmap_t, char key[DIGEST_LEN], digestmap_) | |
DEFINE_MAP_STRUCTS (digest256map_t, uint8_t key[DIGEST256_LEN], digest256map_) | |
static int | strmap_entries_eq (const strmap_entry_t *a, const strmap_entry_t *b) |
static unsigned int | strmap_entry_hash (const strmap_entry_t *a) |
static int | digestmap_entries_eq (const digestmap_entry_t *a, const digestmap_entry_t *b) |
static unsigned int | digestmap_entry_hash (const digestmap_entry_t *a) |
static int | digest256map_entries_eq (const digest256map_entry_t *a, const digest256map_entry_t *b) |
static unsigned int | digest256map_entry_hash (const digest256map_entry_t *a) |
HT_PROTOTYPE (strmap_impl, strmap_entry_t, node, strmap_entry_hash, strmap_entries_eq) | |
HT_GENERATE2 (strmap_impl, strmap_entry_t, node, strmap_entry_hash, strmap_entries_eq, 0.6, tor_reallocarray_, tor_free_) | |
HT_PROTOTYPE (digestmap_impl, digestmap_entry_t, node, digestmap_entry_hash, digestmap_entries_eq) | |
HT_GENERATE2 (digestmap_impl, digestmap_entry_t, node, digestmap_entry_hash, digestmap_entries_eq, 0.6, tor_reallocarray_, tor_free_) | |
HT_PROTOTYPE (digest256map_impl, digest256map_entry_t, node, digest256map_entry_hash, digest256map_entries_eq) | |
HT_GENERATE2 (digest256map_impl, digest256map_entry_t, node, digest256map_entry_hash, digest256map_entries_eq, 0.6, tor_reallocarray_, tor_free_) | |
static void | strmap_entry_free_ (strmap_entry_t *ent) |
static void | digestmap_entry_free_ (digestmap_entry_t *ent) |
static void | digest256map_entry_free_ (digest256map_entry_t *ent) |
static void | strmap_assign_tmp_key (strmap_entry_t *ent, const char *key) |
static void | digestmap_assign_tmp_key (digestmap_entry_t *ent, const char *key) |
static void | digest256map_assign_tmp_key (digest256map_entry_t *ent, const uint8_t *key) |
static void | strmap_assign_key (strmap_entry_t *ent, const char *key) |
static void | digestmap_assign_key (digestmap_entry_t *ent, const char *key) |
static void | digest256map_assign_key (digest256map_entry_t *ent, const uint8_t *key) |
void * | strmap_set_lc (strmap_t *map, const char *key, void *val) |
void * | strmap_get_lc (const strmap_t *map, const char *key) |
void * | strmap_remove_lc (strmap_t *map, const char *key) |
Hash-table implementations of a string-to-void* map, and of a digest-to-void* map.
Definition in file map.c.
#define DEFINE_MAP_STRUCTS | ( | maptype, | |
keydecl, | |||
prefix | |||
) |
Helper: Declare an entry type and a map type to implement a mapping using ht.h. The map type will be called maptype. The key part of each entry is declared using the C declaration keydecl. All functions and types associated with the map get prefixed with prefix
#define digest256map_entry_free | ( | ent | ) | FREE_AND_NULL(digest256map_entry_t, digest256map_entry_free_, (ent)) |
#define digestmap_entry_free | ( | ent | ) | FREE_AND_NULL(digestmap_entry_t, digestmap_entry_free_, (ent)) |
#define IMPLEMENT_MAP_FNS | ( | maptype, | |
keytype, | |||
prefix | |||
) |
Macro: implement all the functions for a map that are declared in map.h by the DECLARE_MAP_FNS() macro. You must additionally define a prefix_entry_free_() function to free entries (and their keys), a prefix_assign_tmp_key() function to temporarily set a stack-allocated entry to hold a key, and a prefix_assign_key() function to set a heap-allocated entry to hold a key.
#define strmap_entry_free | ( | ent | ) | FREE_AND_NULL(strmap_entry_t, strmap_entry_free_, (ent)) |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
void * strmap_get_lc | ( | const strmap_t * | map, |
const char * | key | ||
) |
Same as strmap_get, but first converts key to lowercase.
Definition at line 360 of file map.c.
Referenced by addressmap_have_mapping(), addressmap_match_superdomains(), geoip_get_country(), or_state_remove_obsolete_lines(), and routerset_contains2().
void * strmap_remove_lc | ( | strmap_t * | map, |
const char * | key | ||
) |
void * strmap_set_lc | ( | strmap_t * | map, |
const char * | key, | ||
void * | val | ||
) |
Same as strmap_set, but first converts key to lowercase.
Definition at line 346 of file map.c.
Referenced by or_state_remove_obsolete_lines().