Rewrite global zipping buffer function

Take advantage of the new method, remove a method that is not recommended for use.
This commit is contained in:
Eladash 2023-11-27 15:31:33 +02:00 committed by Elad Ashkenazi
parent 8e31f7fb07
commit ac19a50f5f
5 changed files with 41 additions and 64 deletions

View file

@ -10,6 +10,7 @@
#include "util/v128.hpp"
#include "util/simd.hpp"
#include "Crypto/unzip.h"
#include <charconv>
#ifdef __linux__
@ -1170,17 +1171,19 @@ public:
//fs::file(name, fs::rewrite).write(obj.getBufferStart(), obj.getBufferSize());
name.append(".gz");
const std::vector<u8> zbuf = zip(reinterpret_cast<const u8*>(obj.getBufferStart()), obj.getBufferSize());
fs::file module_file(name, fs::rewrite);
if (zbuf.empty())
if (!module_file)
{
jit_log.error("LLVM: Failed to compress module: %s", _module->getName().data());
jit_log.error("LLVM: Failed to create module file: %s (%s)", name, fs::g_tls_error);
return;
}
if (!fs::write_file(name, fs::rewrite, zbuf.data(), zbuf.size()))
if (!zip(obj.getBufferStart(), obj.getBufferSize(), module_file))
{
jit_log.error("LLVM: Failed to create module file: %s (%s)", name, fs::g_tls_error);
jit_log.error("LLVM: Failed to compress module: %s", _module->getName().data());
module_file.close();
fs::remove_file(name);
return;
}