Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
a3360ea0
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
a3360ea0
编写于
12月 17, 2021
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refact
上级
91a36a51
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
27 addition
and
24 deletion
+27
-24
include/util/mallocator.h
include/util/mallocator.h
+20
-15
source/dnode/vnode/impl/src/vnodeBufferPool.c
source/dnode/vnode/impl/src/vnodeBufferPool.c
+1
-5
source/dnode/vnode/tsdb/src/tsdbMemTable.c
source/dnode/vnode/tsdb/src/tsdbMemTable.c
+3
-3
source/util/src/mallocator.c
source/util/src/mallocator.c
+3
-1
未找到文件。
include/util/mallocator.h
浏览文件 @
a3360ea0
...
...
@@ -22,23 +22,28 @@
extern
"C"
{
#endif
typedef
struct
SMemAllocator
SMemAllocator
;
typedef
struct
SMemAllocatorFactory
SMemAllocatorFactory
;
struct
SMemAllocator
{
// Memory allocator
#define TD_MEM_ALCT(TYPE) \
struct { \
void *(*malloc_)(struct TYPE *, uint64_t size); \
void (*free_)(struct TYPE *, void *ptr); \
}
#define TD_MA_MALLOC_FUNC(TMA) (TMA)->malloc_
#define TD_MA_FREE_FUNC(TMA) (TMA)->free_
#define TD_MA_MALLOC(TMA, SIZE) (*((TMA)->malloc_))(TMA, (SIZE))
#define TD_MA_FREE(TMA, PTR) (*((TMA)->free_))(TMA, (PTR))
typedef
struct
SMemAllocator
{
void
*
impl
;
void
*
(
*
malloc
)(
SMemAllocator
*
,
uint64_t
size
);
void
*
(
*
calloc
)(
SMemAllocator
*
,
uint64_t
nmemb
,
uint64_t
size
);
void
*
(
*
realloc
)(
SMemAllocator
*
,
void
*
ptr
,
uint64_t
size
);
void
(
*
free
)(
SMemAllocator
*
,
void
*
ptr
);
uint64_t
(
*
usage
)(
SMemAllocator
*
);
};
struct
SMemAllocatorFactory
{
TD_MEM_ALCT
(
SMemAllocator
);
}
SMemAllocator
;
typedef
struct
SMemAllocatorFactory
{
void
*
impl
;
SMemAllocator
*
(
*
create
)(
SMemAllocatorFactory
*
);
void
(
*
destroy
)(
SMemAllocatorFactory
*
,
SMemAllocator
*
);
};
SMemAllocator
*
(
*
create
)(
struct
SMemAllocatorFactory
*
);
void
(
*
destroy
)(
struct
SMemAllocatorFactory
*
,
SMemAllocator
*
);
}
SMemAllocatorFactory
;
#ifdef __cplusplus
}
...
...
source/dnode/vnode/impl/src/vnodeBufferPool.c
浏览文件 @
a3360ea0
...
...
@@ -168,11 +168,7 @@ static SMemAllocator *vBufPoolCreateMA(SMemAllocatorFactory *pMAF) {
pWrapper
->
pVMA
=
pVnode
->
pBufPool
->
inuse
;
pMA
->
impl
=
pWrapper
;
pMA
->
malloc
=
vmaMaloocCb
;
pMA
->
calloc
=
NULL
;
pMA
->
realloc
=
NULL
;
pMA
->
free
=
NULL
;
pMA
->
usage
=
NULL
;
TD_MA_MALLOC_FUNC
(
pMA
)
=
vmaMaloocCb
;
return
pMA
;
}
...
...
source/dnode/vnode/tsdb/src/tsdbMemTable.c
浏览文件 @
a3360ea0
...
...
@@ -50,7 +50,7 @@ STsdbMemTable *tsdbNewMemTable(SMemAllocatorFactory *pMAF) {
pMA
=
(
*
pMAF
->
create
)(
pMAF
);
ASSERT
(
pMA
!=
NULL
);
pMemTable
=
(
STsdbMemTable
*
)
((
*
pMA
->
malloc
)(
pMA
,
sizeof
(
*
pMemTable
)
));
pMemTable
=
(
STsdbMemTable
*
)
TD_MA_MALLOC
(
pMA
,
sizeof
(
*
pMemTable
));
if
(
pMemTable
==
NULL
)
{
(
*
pMAF
->
destroy
)(
pMAF
,
pMA
);
return
NULL
;
...
...
@@ -71,7 +71,7 @@ STsdbMemTable *tsdbNewMemTable(SMemAllocatorFactory *pMAF) {
void
tsdbFreeMemTable
(
SMemAllocatorFactory
*
pMAF
,
STsdbMemTable
*
pMemTable
)
{
SMemAllocator
*
pMA
=
pMemTable
->
pMA
;
if
(
pMA
->
free
)
{
if
(
TD_MA_FREE_FUNC
(
pMA
)
!=
NULL
)
{
// TODO
ASSERT
(
0
);
}
...
...
@@ -81,7 +81,7 @@ void tsdbFreeMemTable(SMemAllocatorFactory *pMAF, STsdbMemTable *pMemTable) {
int
tsdbInsertDataToMemTable
(
STsdbMemTable
*
pMemTable
,
SSubmitMsg
*
pMsg
)
{
SMemAllocator
*
pMA
=
pMemTable
->
pMA
;
STbData
*
pTbData
=
(
STbData
*
)
((
*
pMA
->
malloc
)(
pMA
,
sizeof
(
*
pTbData
)
));
STbData
*
pTbData
=
(
STbData
*
)
TD_MA_MALLOC
(
pMA
,
sizeof
(
*
pTbData
));
if
(
pTbData
==
NULL
)
{
// TODO
}
...
...
source/util/src/mallocator.c
浏览文件 @
a3360ea0
...
...
@@ -16,6 +16,7 @@
#include "mallocator.h"
/* ------------------------ HEAP ALLOCATOR ------------------------ */
#if 0
typedef struct {
size_t tusage;
} SHeapAllocator;
...
...
@@ -104,4 +105,5 @@ static size_t haUsage(SMemAllocator *pma) { return ((SHeapAllocator *)(pma->impl
/* ------------------------ ARENA ALLOCATOR ------------------------ */
typedef struct {
size_t usage;
}
SArenaAllocator
;
\ No newline at end of file
} SArenaAllocator;
#endif
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录