fix(util): fix the new size remaining bug.

This commit is contained in:
Haojun Liao 2024-02-29 11:34:57 +08:00
parent 6bc12c8728
commit b744eabce0
1 changed files with 4 additions and 2 deletions

View File

@ -92,9 +92,11 @@ int32_t taosArrayEnsureCap(SArray* pArray, size_t newCap) {
if (newCap * pArray->elemSize > BOUNDARY_SIZE) {
factor = BOUNDARY_SMALL_FACTOR;
}
size_t tsize = (pArray->capacity * factor);
while (newCap > tsize) {
tsize = (tsize * factor);
size_t newSize = (tsize * factor);
tsize = (newSize == tsize) ? (tsize + 2) : newSize;
}
pArray->pData = taosMemoryRealloc(pArray->pData, tsize * pArray->elemSize);