未验证 提交 b7e29f0e 编写于 作者: S slguan 提交者: GitHub

Merge pull request #748 from taosdata/feature/liaohj

[TBASE-1197]fix memory realloc bug
...@@ -106,6 +106,8 @@ void tscAddSpecialColumnForSelect(SSqlCmd* pCmd, int32_t outputColIndex, int16_t ...@@ -106,6 +106,8 @@ void tscAddSpecialColumnForSelect(SSqlCmd* pCmd, int32_t outputColIndex, int16_t
SSchema* pColSchema, int16_t isTag); SSchema* pColSchema, int16_t isTag);
void addRequiredTagColumn(SSqlCmd* pCmd, int32_t tagColIndex, int32_t tableIndex); void addRequiredTagColumn(SSqlCmd* pCmd, int32_t tagColIndex, int32_t tableIndex);
//TODO refactor, remove
void SStringFree(SString* str); void SStringFree(SString* str);
void SStringCopy(SString* pDest, const SString* pSrc); void SStringCopy(SString* pDest, const SString* pSrc);
SString SStringCreate(const char* str); SString SStringCreate(const char* str);
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#include "tschemautil.h" #include "tschemautil.h"
#include "tsocket.h" #include "tsocket.h"
static int32_t getToStringLength(char *pData, int32_t length, int32_t type) { static int32_t getToStringLength(const char *pData, int32_t length, int32_t type) {
char buf[512] = {0}; char buf[512] = {0};
int32_t len = 0; int32_t len = 0;
......
...@@ -1643,7 +1643,7 @@ int32_t SStringEnsureRemain(SString* pStr, int32_t size) { ...@@ -1643,7 +1643,7 @@ int32_t SStringEnsureRemain(SString* pStr, int32_t size) {
} }
// remain space is insufficient, allocate more spaces // remain space is insufficient, allocate more spaces
int32_t inc = (size < MIN_ALLOC_SIZE) ? size : MIN_ALLOC_SIZE; int32_t inc = (size >= MIN_ALLOC_SIZE) ? size : MIN_ALLOC_SIZE;
if (inc < (pStr->alloc >> 1)) { if (inc < (pStr->alloc >> 1)) {
inc = (pStr->alloc >> 1); inc = (pStr->alloc >> 1);
} }
...@@ -1670,6 +1670,7 @@ int32_t SStringEnsureRemain(SString* pStr, int32_t size) { ...@@ -1670,6 +1670,7 @@ int32_t SStringEnsureRemain(SString* pStr, int32_t size) {
} }
memset(tmp + pStr->n, 0, inc); memset(tmp + pStr->n, 0, inc);
pStr->alloc = newsize;
pStr->z = tmp; pStr->z = tmp;
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
......
...@@ -13,22 +13,6 @@ ...@@ -13,22 +13,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/types.h>
#include <stdarg.h>
#include <ctype.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <pthread.h>
#include <stdbool.h>
#include <stdint.h>
#include <semaphore.h>
#include "os.h" #include "os.h"
#include "tutil.h" #include "tutil.h"
#include "tglobalcfg.h" #include "tglobalcfg.h"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册