atom_table.c

Include dependency graph for atom_table.c:

digraph {
    graph [bgcolor="#00000000"]
    node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2]
    edge [color="#1414CE"]
    "3" [label="stdbool.h" tooltip="stdbool.h"]
    "4" [label="atom.h" tooltip="atom.h"]
    "11" [label="utils.h" tooltip="utils.h"]
    "5" [label="stdint.h" tooltip="stdint.h"]
    "6" [label="stdlib.h" tooltip="stdlib.h"]
    "10" [label="stddef.h" tooltip="stddef.h"]
    "1" [label="/__w/AtomVM/AtomVM/src/libAtomVM/atom_table.c" tooltip="/__w/AtomVM/AtomVM/src/libAtomVM/atom_table.c" fillcolor="#BFBFBF"]
    "2" [label="atom_table.h" tooltip="atom_table.h"]
    "7" [label="string.h" tooltip="string.h"]
    "8" [label="smp.h" tooltip="smp.h"]
    "9" [label="unicode.h" tooltip="unicode.h"]
    "12" [label="stdio.h" tooltip="stdio.h"]
    "4" -> "5" [dir=forward tooltip="include"]
    "4" -> "6" [dir=forward tooltip="include"]
    "11" -> "10" [dir=forward tooltip="include"]
    "11" -> "12" [dir=forward tooltip="include"]
    "11" -> "6" [dir=forward tooltip="include"]
    "1" -> "2" [dir=forward tooltip="include"]
    "1" -> "3" [dir=forward tooltip="include"]
    "1" -> "5" [dir=forward tooltip="include"]
    "1" -> "6" [dir=forward tooltip="include"]
    "1" -> "7" [dir=forward tooltip="include"]
    "1" -> "4" [dir=forward tooltip="include"]
    "1" -> "8" [dir=forward tooltip="include"]
    "1" -> "9" [dir=forward tooltip="include"]
    "1" -> "11" [dir=forward tooltip="include"]
    "2" -> "3" [dir=forward tooltip="include"]
    "2" -> "4" [dir=forward tooltip="include"]
    "8" -> "3" [dir=forward tooltip="include"]
    "9" -> "3" [dir=forward tooltip="include"]
    "9" -> "10" [dir=forward tooltip="include"]
    "9" -> "5" [dir=forward tooltip="include"]
}

Defines

SMP_RDLOCK(htable) smp_rwlock_rdlock(htable->lock)
SMP_WRLOCK(htable) smp_rwlock_wrlock(htable->lock)
SMP_UNLOCK(htable) smp_rwlock_unlock(htable->lock)
DEFAULT_SIZE 8
CAPACITY_INCREASE 8
ATOM_TABLE_THRESHOLD(capacity) (capacity + (capacity >> 2))
ATOM_TABLE_NEW_CAPACITY(new_count) (new_count + CAPACITY_INCREASE)

Functions

static struct HNodeGroup *new_node_group(struct AtomTable *table, int len)
struct AtomTable *atom_table_new()
void atom_table_destroy(struct AtomTable *table)
int atom_table_count(struct AtomTable *table)
static unsigned long sdbm_hash(const unsigned char *str, int len)
static inline struct HNode *get_node_from_bucket(const struct AtomTable *hash_table, unsigned long bucket_index, AtomString string)
static inline struct HNode *get_node_with_hash(const struct AtomTable *hash_table, AtomString string, unsigned long hash)
static inline struct HNode *get_node(const struct AtomTable *hash_table, AtomString string)
long atom_table_get_index(struct AtomTable *table, AtomString string)
static struct HNode *get_node_using_index(struct AtomTable *table, long index)
AtomString atom_table_get_atom_string(struct AtomTable *table, long index)
int atom_table_cmp_using_atom_index(struct AtomTable *table, int t_atom_index, int other_atom_index)
atom_ref_t atom_table_get_atom_ptr_and_len(struct AtomTable *table, long index, size_t *out_len)
bool atom_table_is_atom_ref_ascii(struct AtomTable *table, atom_ref_t atom)
void atom_table_write_bytes(struct AtomTable *table, atom_ref_t atom, size_t buf_len, void *outbuf)
void atom_table_write_cstring(struct AtomTable *table, atom_ref_t atom, size_t buf_len, char *outbuf)
static inline void init_node(struct HNode *node, AtomString atom, long index)
static inline void insert_node_into_bucket(struct AtomTable *table, int bucket_index, struct HNode *node)
static inline long insert_node(struct AtomTable *table, struct HNodeGroup *node_group, unsigned long bucket_index, AtomString string)
static bool do_rehash(struct AtomTable *table, int new_capacity)
static inline bool maybe_rehash(struct AtomTable *table, int new_entries)
long atom_table_ensure_atom(struct AtomTable *table, AtomString string, enum AtomTableCopyOpt opts)
int atom_table_ensure_atoms(struct AtomTable *table, const void *atoms, int count, int *translate_table)
struct HNode

Collaboration diagram for HNode:

digraph {
    graph [bgcolor="#00000000"]
    node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2]
    edge [color="#1414CE"]
    "1" [label="HNode" tooltip="HNode" fillcolor="#BFBFBF"]
    "1" -> "1" [dir=forward tooltip="usage"]
}

Public Members

struct HNode *next
AtomString key
long index
struct HNodeGroup

Collaboration diagram for HNodeGroup:

digraph {
    graph [bgcolor="#00000000"]
    node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2]
    edge [color="#1414CE"]
    "1" [label="HNodeGroup" tooltip="HNodeGroup" fillcolor="#BFBFBF"]
    "2" [label="HNode" tooltip="HNode"]
    "1" -> "2" [dir=forward tooltip="usage"]
    "1" -> "1" [dir=forward tooltip="usage"]
    "2" -> "2" [dir=forward tooltip="usage"]
}

Public Members

struct HNodeGroup *next
long first_index
uint16_t len
struct HNode nodes[]
struct AtomTable

Collaboration diagram for AtomTable:

digraph {
    graph [bgcolor="#00000000"]
    node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2]
    edge [color="#1414CE"]
    "3" [label="HNodeGroup" tooltip="HNodeGroup"]
    "1" [label="AtomTable" tooltip="AtomTable" fillcolor="#BFBFBF"]
    "2" [label="HNode" tooltip="HNode"]
    "3" -> "2" [dir=forward tooltip="usage"]
    "3" -> "3" [dir=forward tooltip="usage"]
    "1" -> "2" [dir=forward tooltip="usage"]
    "1" -> "3" [dir=forward tooltip="usage"]
    "2" -> "2" [dir=forward tooltip="usage"]
}

Public Members

int capacity
int count
int last_node_group_avail
RWLock *lock
struct HNode **buckets
struct HNodeGroup *first_node_group
struct HNodeGroup *last_node_group