提交 d66cba75 编写于 作者: H Hongze Cheng

more

上级 2c053411
......@@ -20,17 +20,36 @@
extern "C" {
#endif
#define TD_LIST_NODE(S) \
struct { \
S *prev_; \
S *next_; \
// Single linked list
#define TD_SLIST_NODE(TYPE) \
struct { \
struct type *sl_next_; \
}
#define TD_LIST(S) \
struct { \
S * head_; \
S * tail_; \
int neles_; \
#define TD_SLIST(TYPE) \
struct { \
struct TYPE *sl_head_; \
}
#define TD_SLIST_NODE_NEXT(sln) (sln)->sl_next_
#define tSListInit(sl) \
do { \
(sl)->sl_head_ = NULL; \
} while (0)
// Double linked list
#define TD_DLIST_NODE(S) \
struct { \
S *prev_; \
S *next_; \
}
#define TD_DLIST(S) \
struct { \
S * head_; \
S * tail_; \
int neles_; \
}
#define tlistInit(l) \
......@@ -84,12 +103,12 @@ extern "C" {
// List iterator
#define TD_LIST_FITER 0
#define TD_LIST_BITER 1
#define TD_LIST_ITER(S) \
struct { \
int it_dir_; \
S * it_next_; \
S * it_ptr_; \
TD_LIST(S) * it_list_; \
#define TD_LIST_ITER(S) \
struct { \
int it_dir_; \
S * it_next_; \
S * it_ptr_; \
TD_DLIST(S) * it_list_; \
}
#define tlistIterInit(it, l, dir) \
......
......@@ -26,18 +26,18 @@ typedef struct SVArenaNode SVArenaNode;
typedef struct SVMemAllocator SVMemAllocator;
struct SVArenaNode {
TD_LIST_NODE(SVArenaNode);
TD_DLIST_NODE(SVArenaNode);
uint64_t size; // current node size
void * ptr;
char data[];
};
struct SVMemAllocator {
TD_LIST_NODE(SVMemAllocator);
TD_DLIST_NODE(SVMemAllocator);
uint64_t capacity;
uint64_t ssize;
uint64_t lsize;
TD_LIST(SVArenaNode) nlist;
TD_DLIST(SVArenaNode) nlist;
};
SVMemAllocator *vmaCreate(uint64_t capacity, uint64_t ssize, uint64_t lsize);
......
......@@ -19,8 +19,8 @@
#define VNODE_BUF_POOL_SHARDS 3
struct SVBufPool {
TD_LIST(SVMemAllocator) free;
TD_LIST(SVMemAllocator) incycle;
TD_DLIST(SVMemAllocator) free;
TD_DLIST(SVMemAllocator) incycle;
SVMemAllocator *inuse;
// MAF for submodules
// SMemAllocatorFactory maf;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册