提交 6f6fd3e1 编写于 作者: dengyihao's avatar dengyihao

fix compile error

上级 328687ed
......@@ -36,19 +36,19 @@ extern "C" {
// #endif // ifndef ALLOW_FORBID_FUNC
#endif // if !defined(WINDOWS)
// #define taosMemoryFree malloc
#define taosMemoryMalloc malloc
#define taosMemoryCalloc calloc
#define taosMemoryRealloc realloc
#define taosMemoryFree free
// // #define taosMemoryFree malloc
// #define taosMemoryMalloc malloc
// #define taosMemoryCalloc calloc
// #define taosMemoryRealloc realloc
// #define taosMemoryFree free
int32_t taosMemoryDbgInit();
int32_t taosMemoryDbgInitRestore();
// void *taosMemoryMalloc(int64_t size);
// void *taosMemoryCalloc(int64_t num, int64_t size);
// void *taosMemoryRealloc(void *ptr, int64_t size);
char *taosStrdup(const char *ptr);
// void taosMemoryFree(void *ptr);
void *taosMemoryMalloc(int64_t size);
void *taosMemoryCalloc(int64_t num, int64_t size);
void *taosMemoryRealloc(void *ptr, int64_t size);
char *taosStrdup(const char *ptr);
void taosMemoryFree(void *ptr);
int64_t taosMemorySize(void *ptr);
void taosPrintBackTrace();
void taosMemoryTrim(int32_t size);
......
......@@ -1040,6 +1040,9 @@ int32_t streamStateGetKVByCur_rocksdb(SStreamStateCur* pCur, SWinKey* pKey, cons
if (pKtmp->opNum != pCur->number) {
return -1;
}
size_t vlen = 0;
if (pVal != NULL) *pVal = (char*)rocksdb_iter_value(pCur->iter, &vlen);
if (pVLen != NULL) *pVLen = vlen;
*pKey = pKtmp->key;
return 0;
}
......
......@@ -254,64 +254,64 @@ int32_t taosMemoryDbgInitRestore() {
#endif
}
// void *taosMemoryMalloc(int64_t size) {
// #ifdef USE_TD_MEMORY
// void *tmp = malloc(size + sizeof(TdMemoryInfo));
// if (tmp == NULL) return NULL;
// TdMemoryInfoPtr pTdMemoryInfo = (TdMemoryInfoPtr)tmp;
// pTdMemoryInfo->memorySize = size;
// pTdMemoryInfo->symbol = TD_MEMORY_SYMBOL;
// taosBackTrace(pTdMemoryInfo->stackTrace, TD_MEMORY_STACK_TRACE_DEPTH);
// return (char *)tmp + sizeof(TdMemoryInfo);
// #else
// return malloc(size);
// #endif
// }
void *taosMemoryMalloc(int64_t size) {
#ifdef USE_TD_MEMORY
void *tmp = malloc(size + sizeof(TdMemoryInfo));
if (tmp == NULL) return NULL;
// void *taosMemoryCalloc(int64_t num, int64_t size) {
// #ifdef USE_TD_MEMORY
// int32_t memorySize = num * size;
// char *tmp = calloc(memorySize + sizeof(TdMemoryInfo), 1);
// if (tmp == NULL) return NULL;
// TdMemoryInfoPtr pTdMemoryInfo = (TdMemoryInfoPtr)tmp;
// pTdMemoryInfo->memorySize = memorySize;
// pTdMemoryInfo->symbol = TD_MEMORY_SYMBOL;
// taosBackTrace(pTdMemoryInfo->stackTrace, TD_MEMORY_STACK_TRACE_DEPTH);
// return (char *)tmp + sizeof(TdMemoryInfo);
// #else
// return calloc(num, size);
// #endif
// }
TdMemoryInfoPtr pTdMemoryInfo = (TdMemoryInfoPtr)tmp;
pTdMemoryInfo->memorySize = size;
pTdMemoryInfo->symbol = TD_MEMORY_SYMBOL;
taosBackTrace(pTdMemoryInfo->stackTrace, TD_MEMORY_STACK_TRACE_DEPTH);
// void *taosMemoryRealloc(void *ptr, int64_t size) {
// #ifdef USE_TD_MEMORY
// if (ptr == NULL) return taosMemoryMalloc(size);
return (char *)tmp + sizeof(TdMemoryInfo);
#else
return malloc(size);
#endif
}
// TdMemoryInfoPtr pTdMemoryInfo = (TdMemoryInfoPtr)((char *)ptr - sizeof(TdMemoryInfo));
// ASSERT(pTdMemoryInfo->symbol == TD_MEMORY_SYMBOL);
// if (tpTdMemoryInfo->symbol != TD_MEMORY_SYMBOL) {
// +return NULL;
// +
// }
void *taosMemoryCalloc(int64_t num, int64_t size) {
#ifdef USE_TD_MEMORY
int32_t memorySize = num * size;
char *tmp = calloc(memorySize + sizeof(TdMemoryInfo), 1);
if (tmp == NULL) return NULL;
// TdMemoryInfo tdMemoryInfo;
// memcpy(&tdMemoryInfo, pTdMemoryInfo, sizeof(TdMemoryInfo));
TdMemoryInfoPtr pTdMemoryInfo = (TdMemoryInfoPtr)tmp;
pTdMemoryInfo->memorySize = memorySize;
pTdMemoryInfo->symbol = TD_MEMORY_SYMBOL;
taosBackTrace(pTdMemoryInfo->stackTrace, TD_MEMORY_STACK_TRACE_DEPTH);
// void *tmp = realloc(pTdMemoryInfo, size + sizeof(TdMemoryInfo));
// if (tmp == NULL) return NULL;
return (char *)tmp + sizeof(TdMemoryInfo);
#else
return calloc(num, size);
#endif
}
// memcpy(tmp, &tdMemoryInfo, sizeof(TdMemoryInfo));
// ((TdMemoryInfoPtr)tmp)->memorySize = size;
void *taosMemoryRealloc(void *ptr, int64_t size) {
#ifdef USE_TD_MEMORY
if (ptr == NULL) return taosMemoryMalloc(size);
// return (char *)tmp + sizeof(TdMemoryInfo);
// #else
// return realloc(ptr, size);
// #endif
// }
TdMemoryInfoPtr pTdMemoryInfo = (TdMemoryInfoPtr)((char *)ptr - sizeof(TdMemoryInfo));
ASSERT(pTdMemoryInfo->symbol == TD_MEMORY_SYMBOL);
if (tpTdMemoryInfo->symbol != TD_MEMORY_SYMBOL) {
+return NULL;
+
}
TdMemoryInfo tdMemoryInfo;
memcpy(&tdMemoryInfo, pTdMemoryInfo, sizeof(TdMemoryInfo));
void *tmp = realloc(pTdMemoryInfo, size + sizeof(TdMemoryInfo));
if (tmp == NULL) return NULL;
memcpy(tmp, &tdMemoryInfo, sizeof(TdMemoryInfo));
((TdMemoryInfoPtr)tmp)->memorySize = size;
return (char *)tmp + sizeof(TdMemoryInfo);
#else
return realloc(ptr, size);
#endif
}
char *taosStrdup(const char *ptr) {
#ifdef USE_TD_MEMORY
......@@ -334,21 +334,21 @@ char *taosStrdup(const char *ptr) {
#endif
}
// void taosMemoryFree(void *ptr) {
// if (NULL == ptr) return;
// #ifdef USE_TD_MEMORY
// TdMemoryInfoPtr pTdMemoryInfo = (TdMemoryInfoPtr)((char *)ptr - sizeof(TdMemoryInfo));
// if (pTdMemoryInfo->symbol == TD_MEMORY_SYMBOL) {
// pTdMemoryInfo->memorySize = 0;
// // memset(pTdMemoryInfo, 0, sizeof(TdMemoryInfo));
// free(pTdMemoryInfo);
// } else {
// free(ptr);
// }
// #else
// return free(ptr);
// #endif
// }
void taosMemoryFree(void *ptr) {
if (NULL == ptr) return;
#ifdef USE_TD_MEMORY
TdMemoryInfoPtr pTdMemoryInfo = (TdMemoryInfoPtr)((char *)ptr - sizeof(TdMemoryInfo));
if (pTdMemoryInfo->symbol == TD_MEMORY_SYMBOL) {
pTdMemoryInfo->memorySize = 0;
// memset(pTdMemoryInfo, 0, sizeof(TdMemoryInfo));
free(pTdMemoryInfo);
} else {
free(ptr);
}
#else
return free(ptr);
#endif
}
int64_t taosMemorySize(void *ptr) {
if (ptr == NULL) return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册