byedpi/mpool.h

36 lines
601 B
C
Raw 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-03-08 00:37:02 +00:00
struct elem {
2024-04-16 17:55:41 +00:00
int len;
char *data;
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-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-16 16:32:07 +00:00
struct mphdr *mem_pool(bool is_static);
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