use nix build & meson & zlog
This commit is contained in:
parent
0123623742
commit
346768a144
60 changed files with 13739 additions and 0 deletions
44
src/include/htab.h
Normal file
44
src/include/htab.h
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
#if !defined(_HTAB_H_)
|
||||
|
||||
#define _HTAB_H_ 1
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "mylock.h"
|
||||
|
||||
typedef unsigned int (*hash_key_hash_fn_t)(void*);
|
||||
typedef int (*hash_key_cmp_fn_t)(void*, void*);
|
||||
typedef void* (*hash_key_copy_fn_t)(void*);
|
||||
typedef void (*hash_key_free_fn_t)(void*);
|
||||
|
||||
typedef struct {
|
||||
hash_key_hash_fn_t hash;
|
||||
hash_key_cmp_fn_t cmp;
|
||||
hash_key_copy_fn_t copy;
|
||||
hash_key_free_fn_t free;
|
||||
} hash_key_fn_t;
|
||||
|
||||
typedef struct _hent {
|
||||
struct _hent* next;
|
||||
void* key;
|
||||
int64_t data;
|
||||
} hent_t;
|
||||
|
||||
typedef struct {
|
||||
mylock_t lock;
|
||||
int nslots;
|
||||
hash_key_fn_t fn;
|
||||
hent_t** slots;
|
||||
} htab_t;
|
||||
|
||||
extern hash_key_fn_t string_hash_key;
|
||||
extern hash_key_fn_t int_hash_key;
|
||||
|
||||
extern int ht_init(htab_t*, int,
|
||||
hash_key_fn_t);
|
||||
extern void ht_fini(htab_t*);
|
||||
extern hent_t* ht_get(htab_t*, void*);
|
||||
extern hent_t* ht_add(htab_t*, void*);
|
||||
extern int ht_del(htab_t*, void*);
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue