summaryrefslogtreecommitdiffhomepage
path: root/src/hsearch.h
blob: 7e9d77092052c065b457aebe97d8782b72eaaf16 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#ifndef HSEARCH_H
#define HSEARCH_H

#include <stdlib.h>

typedef union htab_value {
	void *p;
	size_t n;
} htab_value;

#define HTV_N(N) (htab_value) {.n = N}
#define HTV_P(P) (htab_value) {.p = P}

struct htab * htab_create(size_t);
void htab_destroy(struct htab *);
htab_value* htab_find(struct htab *, const char* key);
/* same as htab_find, but can retrieve the saved key (for freeing) */
htab_value* htab_find2(struct htab *htab, const char* key, char **saved_key);
int htab_insert(struct htab *, char*, htab_value);
int htab_delete(struct htab *htab, const char* key);
size_t htab_next(struct htab *, size_t iterator, char** key, htab_value **v);

#endif