fix(os): .free func const ptr.
This commit is contained in:
parent
5143c8dbdb
commit
66ea2d6bdc
|
@ -33,13 +33,13 @@ void *taosMemoryMalloc(int32_t size);
|
||||||
void *taosMemoryCalloc(int32_t num, int32_t size);
|
void *taosMemoryCalloc(int32_t num, int32_t size);
|
||||||
void *taosMemoryRealloc(void *ptr, int32_t size);
|
void *taosMemoryRealloc(void *ptr, int32_t size);
|
||||||
void *taosMemoryStrDup(void *ptr);
|
void *taosMemoryStrDup(void *ptr);
|
||||||
void taosMemoryFree(const void *ptr);
|
void taosMemoryFree(void *ptr);
|
||||||
int32_t taosMemorySize(void *ptr);
|
int32_t taosMemorySize(void *ptr);
|
||||||
|
|
||||||
#define taosMemoryFreeClear(ptr) \
|
#define taosMemoryFreeClear(ptr) \
|
||||||
do { \
|
do { \
|
||||||
if (ptr) { \
|
if (ptr) { \
|
||||||
taosMemoryFree(ptr); \
|
taosMemoryFree((void*)ptr); \
|
||||||
(ptr) = NULL; \
|
(ptr) = NULL; \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
|
@ -292,7 +292,7 @@ void* transCtxDumpBrokenlinkVal(STransCtx* ctx, int32_t* msgType) {
|
||||||
|
|
||||||
void transQueueInit(STransQueue* queue, void (*freeFunc)(const void* arg)) {
|
void transQueueInit(STransQueue* queue, void (*freeFunc)(const void* arg)) {
|
||||||
queue->q = taosArrayInit(2, sizeof(void*));
|
queue->q = taosArrayInit(2, sizeof(void*));
|
||||||
queue->freeFunc = freeFunc;
|
queue->freeFunc = (void (*)(const void*))freeFunc;
|
||||||
}
|
}
|
||||||
bool transQueuePush(STransQueue* queue, void* arg) {
|
bool transQueuePush(STransQueue* queue, void* arg) {
|
||||||
if (queue->q == NULL) {
|
if (queue->q == NULL) {
|
||||||
|
|
|
@ -156,14 +156,14 @@ TEST_F(TransCtxEnv, mergeTest) {
|
||||||
STransCtx *src = (STransCtx *)taosMemoryCalloc(1, sizeof(STransCtx));
|
STransCtx *src = (STransCtx *)taosMemoryCalloc(1, sizeof(STransCtx));
|
||||||
transCtxInit(src);
|
transCtxInit(src);
|
||||||
{
|
{
|
||||||
STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = taosMemoryFree};
|
STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = (void (*)(const void*))taosMemoryFree};
|
||||||
val1.val = taosMemoryMalloc(12);
|
val1.val = taosMemoryMalloc(12);
|
||||||
|
|
||||||
taosHashPut(src->args, &key, sizeof(key), &val1, sizeof(val1));
|
taosHashPut(src->args, &key, sizeof(key), &val1, sizeof(val1));
|
||||||
key++;
|
key++;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = taosMemoryFree};
|
STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = (void (*)(const void*))taosMemoryFree};
|
||||||
val1.val = taosMemoryMalloc(12);
|
val1.val = taosMemoryMalloc(12);
|
||||||
taosHashPut(src->args, &key, sizeof(key), &val1, sizeof(val1));
|
taosHashPut(src->args, &key, sizeof(key), &val1, sizeof(val1));
|
||||||
key++;
|
key++;
|
||||||
|
@ -176,14 +176,14 @@ TEST_F(TransCtxEnv, mergeTest) {
|
||||||
STransCtx *src = (STransCtx *)taosMemoryCalloc(1, sizeof(STransCtx));
|
STransCtx *src = (STransCtx *)taosMemoryCalloc(1, sizeof(STransCtx));
|
||||||
transCtxInit(src);
|
transCtxInit(src);
|
||||||
{
|
{
|
||||||
STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = taosMemoryFree};
|
STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = (void (*)(const void*))taosMemoryFree};
|
||||||
val1.val = taosMemoryMalloc(12);
|
val1.val = taosMemoryMalloc(12);
|
||||||
|
|
||||||
taosHashPut(src->args, &key, sizeof(key), &val1, sizeof(val1));
|
taosHashPut(src->args, &key, sizeof(key), &val1, sizeof(val1));
|
||||||
key++;
|
key++;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = taosMemoryFree};
|
STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = (void (*)(const void*))taosMemoryFree};
|
||||||
val1.val = taosMemoryMalloc(12);
|
val1.val = taosMemoryMalloc(12);
|
||||||
taosHashPut(src->args, &key, sizeof(key), &val1, sizeof(val1));
|
taosHashPut(src->args, &key, sizeof(key), &val1, sizeof(val1));
|
||||||
key++;
|
key++;
|
||||||
|
@ -198,7 +198,7 @@ TEST_F(TransCtxEnv, mergeTest) {
|
||||||
STransCtx *src = (STransCtx *)taosMemoryCalloc(1, sizeof(STransCtx));
|
STransCtx *src = (STransCtx *)taosMemoryCalloc(1, sizeof(STransCtx));
|
||||||
transCtxInit(src);
|
transCtxInit(src);
|
||||||
{
|
{
|
||||||
STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = taosMemoryFree};
|
STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = (void (*)(const void*))taosMemoryFree};
|
||||||
val1.val = taosMemoryCalloc(1, 11);
|
val1.val = taosMemoryCalloc(1, 11);
|
||||||
memcpy(val1.val, val.c_str(), val.size());
|
memcpy(val1.val, val.c_str(), val.size());
|
||||||
|
|
||||||
|
@ -206,7 +206,7 @@ TEST_F(TransCtxEnv, mergeTest) {
|
||||||
key++;
|
key++;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = taosMemoryFree};
|
STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = (void (*)(const void*))taosMemoryFree};
|
||||||
val1.val = taosMemoryCalloc(1, 11);
|
val1.val = taosMemoryCalloc(1, 11);
|
||||||
memcpy(val1.val, val.c_str(), val.size());
|
memcpy(val1.val, val.c_str(), val.size());
|
||||||
taosHashPut(src->args, &key, sizeof(key), &val1, sizeof(val1));
|
taosHashPut(src->args, &key, sizeof(key), &val1, sizeof(val1));
|
||||||
|
|
|
@ -156,7 +156,7 @@ void *taosMemoryStrDup(void *ptr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void taosMemoryFree(const void *ptr) {
|
void taosMemoryFree(void *ptr) {
|
||||||
if (ptr == NULL) return;
|
if (ptr == NULL) return;
|
||||||
|
|
||||||
#ifdef USE_TD_MEMORY
|
#ifdef USE_TD_MEMORY
|
||||||
|
@ -166,10 +166,10 @@ void taosMemoryFree(const void *ptr) {
|
||||||
// memset(pTdMemoryInfo, 0, sizeof(TdMemoryInfo));
|
// memset(pTdMemoryInfo, 0, sizeof(TdMemoryInfo));
|
||||||
free(pTdMemoryInfo);
|
free(pTdMemoryInfo);
|
||||||
} else {
|
} else {
|
||||||
free((void*)ptr);
|
free(ptr);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
return free((void*)ptr);
|
return free(ptr);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue