tools/source/misc/json_writer.cxx | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
New commits: commit 897192f07c1f7863a50e09cdd29e6631550b83ff Author: Noel Grandin <[email protected]> AuthorDate: Sat Oct 2 13:15:40 2021 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Sat Oct 2 19:15:00 2021 +0200 simplify JsonWriter::reallocBuffer by using realloc instead of malloc and copy. spotted by mmeeks Change-Id: Ibac83be597cfaf61f783a265562c5102bbaf29d8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122995 Tested-by: Jenkins Reviewed-by: Noel Grandin <[email protected]> diff --git a/tools/source/misc/json_writer.cxx b/tools/source/misc/json_writer.cxx index b6482329ea55..f002ddc391aa 100644 --- a/tools/source/misc/json_writer.cxx +++ b/tools/source/misc/json_writer.cxx @@ -413,10 +413,7 @@ void JsonWriter::reallocBuffer(int noMoreBytesRequired) { int currentUsed = mPos - mpBuffer; auto newSize = std::max<int>(mSpaceAllocated * 2, (currentUsed + noMoreBytesRequired) * 2); - char* pNew = static_cast<char*>(malloc(newSize)); - memcpy(pNew, mpBuffer, currentUsed); - free(mpBuffer); - mpBuffer = pNew; + mpBuffer = static_cast<char*>(realloc(mpBuffer, newSize)); mPos = mpBuffer + currentUsed; mSpaceAllocated = newSize; }
