diff --git a/src/util/src/tlist.c b/src/util/src/tlist.c index f11a5481f6b5a130b69f9ea352323b70f4a6de07..8844a5f787c1923310ac71a30cc39594ed7f04f8 100644 --- a/src/util/src/tlist.c +++ b/src/util/src/tlist.c @@ -24,7 +24,7 @@ SList *tdListNew(int eleSize) { list->eleSize = eleSize; list->numOfEles = 0; list->head = list->tail = NULL; - return NULL; + return list; } void tdListEmpty(SList *list) { @@ -135,7 +135,7 @@ SListNode *tdListPopNode(SList *list, SListNode *node) { return node; } -void tdListNodeGetData(SList *list, SListNode *node, void *target) { memcpy(node->data, target, list->eleSize); } +void tdListNodeGetData(SList *list, SListNode *node, void *target) { memcpy(target, node->data, list->eleSize); } void tdListInitIter(SList *list, SListIter *pIter, TD_LIST_DIRECTION_T direction) { pIter->direction = direction; diff --git a/src/vnode/tsdb/src/tsdbCache.c b/src/vnode/tsdb/src/tsdbCache.c index 4baedf55a332f6ff063b8c2fe224a23c872c0927..56ec040daf323498c3c8b2416da8f5d40a5e77dc 100644 --- a/src/vnode/tsdb/src/tsdbCache.c +++ b/src/vnode/tsdb/src/tsdbCache.c @@ -23,6 +23,8 @@ STsdbCache *tsdbInitCache(int maxBytes, int cacheBlockSize) { STsdbCache *pCache = (STsdbCache *)calloc(1, sizeof(STsdbCache)); if (pCache == NULL) return NULL; + if (cacheBlockSize < 0) cacheBlockSize = TSDB_DEFAULT_CACHE_BLOCK_SIZE; + pCache->maxBytes = maxBytes; pCache->cacheBlockSize = cacheBlockSize; @@ -83,6 +85,7 @@ void *tsdbAllocFromCache(STsdbCache *pCache, int bytes) { void *ptr = (void *)(pCache->curBlock->data + pCache->curBlock->offset); pCache->curBlock->offset += bytes; pCache->curBlock->remain -= bytes; + memset(ptr, 0, bytes); return ptr; }