#include <pthread.h>
#include <time.h>
#include <stdlib.h>
#include <string.h>
#include "window.h"
#include "../../include/trafilo.h"
Go to the source code of this file.
◆ hashmap_create()
| hashmap_t * hashmap_create |
( |
size_t | num_buckets | ) |
|
Create a hashmap.
- Parameters
-
| num_buckets | Number of buckets in the hashmap. |
- Returns
- Pointer to the newly created hashmap.
◆ hashmap_destroy()
Graceful cleanup of the hashmap.
- Parameters
-
| hashmap | Pointer to the hashmap. |
| state_free | User specified state_free function. |
◆ hashmap_find_or_create()
Find bucket for key; create if absent. Returns with bucket->bucket_lock LOCKED.
- Parameters
-
| hashmap | Target hashmap. |
| key | NUL-terminated string, bucket takes ownership. |
- Returns
- Locked bucket, or NULL on alloc failure.
◆ hashmap_for_each()
| void hashmap_for_each |
( |
hashmap_t * | hashmap, |
|
|
void(* | fn )(bucket_node *bucket, void *arg), |
|
|
void * | arg ) |
For each iteration for operations, calls passed function within lock protection.
- Parameters
-
| hashmap | Pointer to the hashmap. |
| fn | Function with bucket_node and arguments. |
| arg | Arguments for the iterative function. |
◆ hashmap_unlock_bucket()
| void hashmap_unlock_bucket |
( |
hashmap_t * | hashmap, |
|
|
const char * | key ) |
Helper to unlock a locked node.
- Parameters
-
| hashmap | Pointer to the hashmap. |
| key | The key that belongs to the node. |