![]() |
Baseer 0.2.0
Baseer is an advanced binary analysis tool designed to provide deep insights into any file.
|
Simple string-keyed hashmap implementation. More...
#include "b_hashmap.h"Functions | |
| unsigned int | hash (const char *key) |
| Compute hash value of a string key. | |
| hashmap_t * | create_map (void) |
| Allocate and initialize a new hashmap. | |
| void | insert (hashmap_t *map, const char *name, void *bht_node_p) |
| Insert a key-value pair into the hashmap. | |
| void * | get (hashmap_t *map, const char *name) |
| Retrieve a value from the hashmap by key. | |
| void | free_map (hashmap_t *map) |
| Free all memory used by the hashmap. | |
Simple string-keyed hashmap implementation.
This file provides a basic hash table implementation that maps string keys to generic pointer values (void*). It uses separate chaining (linked lists) for collision handling.
| hashmap_t * create_map | ( | void | ) |
Allocate and initialize a new hashmap.
Creates a hashmap with all buckets initialized to NULL.
| void free_map | ( | hashmap_t * | map | ) |
Free all memory used by the hashmap.
Releases all keys, nodes, and the hashmap structure itself. The caller is responsible for freeing values stored inside if they were dynamically allocated.
| map | Pointer to hashmap. |
| void * get | ( | hashmap_t * | map, |
| const char * | name ) |
Retrieve a value from the hashmap by key.
Performs a lookup in the hashmap and returns the pointer associated with the key, if found.
| map | Pointer to hashmap. |
| name | Null-terminated string key. |
| unsigned int hash | ( | const char * | key | ) |
Compute hash value of a string key.
Uses the djb2 algorithm by Dan Bernstein to generate an unsigned integer hash for the given key.
| key | Null-terminated string key. |
| void insert | ( | hashmap_t * | map, |
| const char * | name, | ||
| void * | bht_node_p ) |
Insert a key-value pair into the hashmap.
The key is duplicated internally, so the caller does not need to maintain the lifetime of the original string.
| map | Pointer to hashmap. |
| name | Null-terminated string key. |
| bht_node_p | Pointer to the value to store. |