byedpi/mpool.h

43 lines
758 B
C
Raw Permalink Normal View History

2024-08-07 11:25:26 +00:00
#ifndef MPOOL_H
#define MPOOL_H
2024-04-16 17:55:41 +00:00
#include <stdbool.h>
2024-03-08 18:33:25 +00:00
#include <time.h>
2024-04-16 17:55:41 +00:00
#include "kavl.h"
2024-03-08 18:33:25 +00:00
2024-12-17 02:27:34 +00:00
#define CMP_BYTES 0
#define CMP_BITS 1
2024-12-20 01:15:13 +00:00
#define CMP_HOST 2
2024-12-17 02:27:34 +00:00
2024-03-08 00:37:02 +00:00
struct elem {
2024-04-16 17:55:41 +00:00
int len;
char *data;
2024-12-20 01:15:13 +00:00
unsigned char cmp_type;
2024-12-16 16:32:07 +00:00
KAVL_HEAD(struct elem) head;
};
struct elem_i {
struct elem i;
2024-03-08 00:37:02 +00:00
int m;
2024-03-08 18:33:25 +00:00
time_t time;
2024-03-08 00:37:02 +00:00
};
2024-04-16 17:55:41 +00:00
2024-03-08 00:37:02 +00:00
struct mphdr {
2024-12-16 16:32:07 +00:00
bool static_data;
2024-12-20 01:15:13 +00:00
unsigned char cmp_type;
size_t count;
2024-04-16 17:55:41 +00:00
struct elem *root;
2024-03-08 00:37:02 +00:00
};
2024-04-16 17:55:41 +00:00
2024-12-20 01:15:13 +00:00
struct mphdr *mem_pool(bool is_static, unsigned char cmp_type);
2024-04-16 17:55:41 +00:00
2024-12-16 16:32:07 +00:00
struct elem *mem_get(const struct mphdr *hdr, const char *str, int len);
2024-04-16 17:55:41 +00:00
2024-12-16 16:32:07 +00:00
struct elem *mem_add(struct mphdr *hdr, char *str, int len, size_t ssize);
2024-04-16 17:55:41 +00:00
2024-12-16 16:32:07 +00:00
void mem_delete(struct mphdr *hdr, const char *str, int len);
2024-04-16 17:55:41 +00:00
void mem_destroy(struct mphdr *hdr);
2024-08-07 11:25:26 +00:00
#endif