forked from hufrea/byedpi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mpool.h
42 lines (31 loc) · 758 Bytes
/
mpool.h
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#ifndef MPOOL_H
#define MPOOL_H
#include <stdbool.h>
#include <time.h>
#include "kavl.h"
#define CMP_BYTES 0
#define CMP_BITS 1
#define CMP_HOST 2
struct elem {
int len;
char *data;
unsigned char cmp_type;
KAVL_HEAD(struct elem) head;
};
struct elem_i {
struct elem i;
int m;
time_t time;
};
struct mphdr {
bool static_data;
unsigned char cmp_type;
size_t count;
struct elem *root;
};
struct mphdr *mem_pool(bool is_static, unsigned char cmp_type);
struct elem *mem_get(const struct mphdr *hdr, const char *str, int len);
struct elem *mem_add(struct mphdr *hdr, char *str, int len, size_t ssize);
void mem_delete(struct mphdr *hdr, const char *str, int len);
void mem_destroy(struct mphdr *hdr);
#endif