diff --git a/coding/zip_creator.cpp b/coding/zip_creator.cpp index 2831100f3c..dca31e1674 100644 --- a/coding/zip_creator.cpp +++ b/coding/zip_creator.cpp @@ -13,7 +13,6 @@ #include "std/vector.hpp" #include "std/ctime.hpp" #include "std/algorithm.hpp" -#include "std/unique_ptr.hpp" #include "3party/minizip/zip.h" @@ -58,8 +57,6 @@ void CreateTMZip(tm_zip & res) bool CreateZipFromPathDeflatedAndDefaultCompression(string const & filePath, string const & zipFilePath) { - unique_ptr buffer(new char[ZIP_FILE_BUFFER_SIZE]); - // 2. Open zip file for writing. MY_SCOPE_GUARD(outFileGuard, bind(&my::DeleteFileX, cref(zipFilePath))); ZipHandle zip(zipFilePath); @@ -87,12 +84,13 @@ bool CreateZipFromPathDeflatedAndDefaultCompression(string const & filePath, str uint64_t const fileSize = file.Size(); uint64_t currSize = 0; + char buffer[ZIP_FILE_BUFFER_SIZE]; while (currSize < fileSize) { unsigned int const toRead = min(ZIP_FILE_BUFFER_SIZE, static_cast(fileSize - currSize)); - file.Read(currSize, &buffer[0], toRead); + file.Read(currSize, buffer, toRead); - if (ZIP_OK != zipWriteInFileInZip(zip.Handle(), &buffer[0], toRead)) + if (ZIP_OK != zipWriteInFileInZip(zip.Handle(), buffer, toRead)) return false; currSize += toRead; diff --git a/coding/zip_reader.cpp b/coding/zip_reader.cpp index a2a59b8178..32de85bcbf 100644 --- a/coding/zip_reader.cpp +++ b/coding/zip_reader.cpp @@ -76,8 +76,6 @@ bool ZipFileReader::IsZip(string const & zipContainer) void ZipFileReader::UnzipFile(string const & zipContainer, string const & fileInZip, string const & outFilePath, ProgressFn progressFn) { - unique_ptr buf(new char[ZIP_FILE_BUFFER_SIZE]); - unzFile zip = unzOpen64(zipContainer.c_str()); if (!zip) MYTHROW(OpenZipException, ("Can't get zip file handle", zipContainer)); @@ -100,11 +98,12 @@ void ZipFileReader::UnzipFile(string const & zipContainer, string const & fileIn FileWriter outFile(outFilePath); uint64_t pos = 0; + char buf[ZIP_FILE_BUFFER_SIZE]; while (true) { - int const readBytes = unzReadCurrentFile(zip, &buf[0], ZIP_FILE_BUFFER_SIZE); + int const readBytes = unzReadCurrentFile(zip, buf, ZIP_FILE_BUFFER_SIZE); if (readBytes > 0) - outFile.Write(&buf[0], static_cast(readBytes)); + outFile.Write(buf, static_cast(readBytes)); else if (readBytes < 0) MYTHROW(InvalidZipException, ("Error", readBytes, "while unzipping", fileInZip, "from", zipContainer)); else