This commit is contained in:
hzcheng 2020-03-21 12:13:06 +08:00
parent d5e4fc3201
commit d148a8e9c3
2 changed files with 5 additions and 2 deletions

View File

@ -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;

View File

@ -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;
}