diff options
author | Alex Zolotarev <alex@mapswithme.com> | 2014-10-11 12:47:00 +0400 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 02:27:39 +0300 |
commit | 6b016a3d0c7f7235425e86a419116a39ffe90d28 (patch) | |
tree | 5912aee18cf9eccca0c0d0cf8175a7378af7451f /coding/zip_creator.cpp | |
parent | 64a6968973dff20ed9bca485eaa2f5321861453a (diff) |
[ios] Correct fix of clang optimization crashes
Diffstat (limited to 'coding/zip_creator.cpp')
-rw-r--r-- | coding/zip_creator.cpp | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/coding/zip_creator.cpp b/coding/zip_creator.cpp index 05121112bf..20a2af6e14 100644 --- a/coding/zip_creator.cpp +++ b/coding/zip_creator.cpp @@ -13,6 +13,7 @@ #include "../../std/vector.hpp" #include "../../std/ctime.hpp" #include "../../std/algorithm.hpp" +#include "../../std/unique_ptr.hpp" #include "../../3party/zlib/contrib/minizip/zip.h" @@ -57,11 +58,7 @@ void CreateTMZip(tm_zip & res) bool CreateZipFromPathDeflatedAndDefaultCompression(string const & filePath, string const & zipFilePath) { - /// Prepare buffer at the very beginning to avoid clang 3.5, loop optimization. - /// @todo Need to check with the new XCode (and clang) update. - - size_t const bufSize = ZIP_FILE_BUFFER_SIZE; - vector<char> buffer(bufSize); + unique_ptr<char[]> buffer(new char[ZIP_FILE_BUFFER_SIZE]); // 2. Open zip file for writing. MY_SCOPE_GUARD(outFileGuard, bind(&my::DeleteFileX, cref(zipFilePath))); @@ -93,7 +90,7 @@ bool CreateZipFromPathDeflatedAndDefaultCompression(string const & filePath, str size_t currSize = 0; while (currSize < fileSize) { - size_t const toRead = min(bufSize, fileSize - currSize); + size_t const toRead = min(ZIP_FILE_BUFFER_SIZE, fileSize - currSize); file.Read(currSize, &buffer[0], toRead); if (ZIP_OK != zipWriteInFileInZip(zip.Handle(), &buffer[0], toRead)) |