提交 0ff29030 编写于 作者: Z zhihaop

fix: create SArray with initial capacity

上级 010dea24
......@@ -16,8 +16,6 @@
#ifndef TDENGINE_TSCBULKWRITE_H
#define TDENGINE_TSCBULKWRITE_H
#include <pthread.h>
#include <stdlib.h>
#ifdef __cplusplus
extern "C" {
#endif
......
......@@ -151,7 +151,7 @@ SArray* dispatcherPollAll(SAsyncBulkWriteDispatcher* dispatcher) {
}
pthread_mutex_lock(&dispatcher->mutex);
SArray* statements = taosArrayInit(0, sizeof(SSqlObj*));
SArray* statements = taosArrayInit(atomic_load_32(&dispatcher->bufferSize), sizeof(SSqlObj*));
if (statements == NULL) {
pthread_mutex_unlock(&dispatcher->mutex);
tscError("failed to poll all items: out of memory");
......@@ -166,8 +166,7 @@ SArray* dispatcherPollAll(SAsyncBulkWriteDispatcher* dispatcher) {
}
// get the SSqlObj* from the node.
SSqlObj* item;
memcpy(&item, node->data, sizeof(SSqlObj*));
SSqlObj* item = *((SSqlObj **) node->data);
listNodeFree(node);
atomic_fetch_sub_32(&dispatcher->bufferSize, 1);
atomic_fetch_sub_32(&dispatcher->currentSize, statementGetInsertionRows(item));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册