From 5c5d6eb1fbaf0d5e94ca529c69f3681245b31409 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Tue, 9 Nov 2021 17:52:06 +0800 Subject: [PATCH] refact --- source/dnode/vnode/impl/inc/vnodeDef.h | 2 + .../dnode/vnode/impl/src/vnodeMemAllocator.c | 41 +++++++++++++++++-- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/source/dnode/vnode/impl/inc/vnodeDef.h b/source/dnode/vnode/impl/inc/vnodeDef.h index 12ac04ac8b..3ad7de722e 100644 --- a/source/dnode/vnode/impl/inc/vnodeDef.h +++ b/source/dnode/vnode/impl/inc/vnodeDef.h @@ -18,6 +18,8 @@ #include "mallocator.h" #include "sync.h" +#include "tlockfree.h" + #include "vnode.h" #include "vnodeAllocatorPool.h" #include "vnodeCommit.h" diff --git a/source/dnode/vnode/impl/src/vnodeMemAllocator.c b/source/dnode/vnode/impl/src/vnodeMemAllocator.c index f3e81f38ec..a61b8808da 100644 --- a/source/dnode/vnode/impl/src/vnodeMemAllocator.c +++ b/source/dnode/vnode/impl/src/vnodeMemAllocator.c @@ -15,12 +15,47 @@ #include "vnodeDef.h" -/* ------------------------ Heap Allocator ------------------------ */ typedef struct { uint64_t tsize; uint64_t used; } SVHeapAllocator; +typedef struct SVArenaNode { + struct SVArenaNode *prev; +} SVArenaNode; + +typedef struct { +} SVArenaAllocator; + +typedef struct { + int8_t type; + uint64_t tsize; + T_REF_DECLARE() + union { + SVHeapAllocator vha; + SVArenaAllocator vaa; + }; +} SVMemAllocator; + +SMemAllocator *vnodeCreateMemAllocator(int8_t type, uint64_t size) { + /* TODO */ + return NULL; +} + +void vnodeDestroyMemAllocator(SMemAllocator *pma) { + // TODO +} + +void vnodeRefMemAllocator(SMemAllocator *pma) { + // TODO +} + +void vnodeUnrefMemAllocator(SMemAllocator *pma) { + // TODO +} + +/* ------------------------ Heap Allocator IMPL ------------------------ */ + SMemAllocator *vhaCreate(uint64_t size) { SMemAllocator *pma; @@ -62,6 +97,4 @@ static uint64_t vhaUsage(SMemAllocator *pma) { return 0; } -/* ------------------------ Arena Allocator ------------------------ */ -typedef struct { -} SVArenaAllocator; \ No newline at end of file +/* ------------------------ Arena Allocator IMPL ------------------------ */ \ No newline at end of file