Merge pull request #748 from taosdata/feature/liaohj
[TBASE-1197]fix memory realloc bug
This commit is contained in:
commit
b7e29f0e3d
|
@ -106,6 +106,8 @@ void tscAddSpecialColumnForSelect(SSqlCmd* pCmd, int32_t outputColIndex, int16_t
|
|||
SSchema* pColSchema, int16_t isTag);
|
||||
|
||||
void addRequiredTagColumn(SSqlCmd* pCmd, int32_t tagColIndex, int32_t tableIndex);
|
||||
|
||||
//TODO refactor, remove
|
||||
void SStringFree(SString* str);
|
||||
void SStringCopy(SString* pDest, const SString* pSrc);
|
||||
SString SStringCreate(const char* str);
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include "tschemautil.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};
|
||||
|
||||
int32_t len = 0;
|
||||
|
|
|
@ -1643,7 +1643,7 @@ int32_t SStringEnsureRemain(SString* pStr, int32_t size) {
|
|||
}
|
||||
|
||||
// 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)) {
|
||||
inc = (pStr->alloc >> 1);
|
||||
}
|
||||
|
@ -1670,6 +1670,7 @@ int32_t SStringEnsureRemain(SString* pStr, int32_t size) {
|
|||
}
|
||||
|
||||
memset(tmp + pStr->n, 0, inc);
|
||||
pStr->alloc = newsize;
|
||||
pStr->z = tmp;
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
|
|
@ -13,22 +13,6 @@
|
|||
* 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 "tutil.h"
|
||||
#include "tglobalcfg.h"
|
||||
|
|
Loading…
Reference in New Issue