From fa0b77d19b043c9cd41b267895e401871617042d Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Thu, 13 Aug 2020 11:39:00 +0800 Subject: [PATCH] [td-225] add log if malloc failed. --- src/common/src/tdataformat.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/common/src/tdataformat.c b/src/common/src/tdataformat.c index 0be0216174..e7f40442a0 100644 --- a/src/common/src/tdataformat.c +++ b/src/common/src/tdataformat.c @@ -13,6 +13,7 @@ * along with this program. If not, see . */ #include "tdataformat.h" +#include "tulog.h" #include "talgo.h" #include "tcoding.h" #include "wchar.h" @@ -311,10 +312,14 @@ void dataColSetOffset(SDataCol *pCol, int nEle) { SDataCols *tdNewDataCols(int maxRowSize, int maxCols, int maxRows) { SDataCols *pCols = (SDataCols *)calloc(1, sizeof(SDataCols)); - if (pCols == NULL) return NULL; + if (pCols == NULL) { + uDebug("malloc failure, size:%"PRId64" failed, reason:%s", sizeof(SDataCols), strerror(errno)); + return NULL; + } pCols->cols = (SDataCol *)calloc(maxCols, sizeof(SDataCol)); if (pCols->cols == NULL) { + uDebug("malloc failure, size:%"PRId64" failed, reason:%s", sizeof(SDataCol) * maxCols, strerror(errno)); tdFreeDataCols(pCols); return NULL; } @@ -326,6 +331,7 @@ SDataCols *tdNewDataCols(int maxRowSize, int maxCols, int maxRows) { pCols->buf = malloc(pCols->bufSize); if (pCols->buf == NULL) { + uDebug("malloc failure, size:%"PRId64" failed, reason:%s", sizeof(SDataCol) * maxCols, strerror(errno)); tdFreeDataCols(pCols); return NULL; } -- GitLab