-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathht.h
More file actions
27 lines (17 loc) · 706 Bytes
/
ht.h
File metadata and controls
27 lines (17 loc) · 706 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/* vim: set tabstop=4 shiftwidth=4 softtabstop=4 expandtab: */
#ifndef __HT_H_
#define __HT_H_
#include <string.h>
// callback takes key, val and updates the state, and returns the new state
// at the end
typedef void * (*table_cb_t)(const char *key, void *val, void *state);
struct table_t *table_alloc();
void table_free(struct table_t *);
void *table_get(struct table_t *, const char *);
// run cb on all the entries
void *table_each(struct table_t *, table_cb_t cb, void *state);
// key string managed by the caller and used till table_del
int table_add(struct table_t *, const char *, void *);
// returns the added object after delete
void *table_del(struct table_t *, const char *);
#endif