Skip to content

Commit bb5354e

Browse files
committed
fix build
1 parent 60a1720 commit bb5354e

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/hdiff.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#include "hdiff.h"
2+
#include "../HDiffPatch/libHDiffPatch/HDiff/diff.h"
3+
#include <stdexcept>
4+
5+
#define _CompressPlugin_lzma2
6+
#define _IsNeedIncludeDefaultCompressHead 0
7+
#include "../lzma/C/Lzma2Dec.h"
8+
#include "../lzma/C/Lzma2Enc.h"
9+
#include "../lzma/C/MtCoder.h"
10+
#include "../HDiffPatch/compress_plugin_demo.h"
11+
#include "../HDiffPatch/decompress_plugin_demo.h"
12+
13+
void hdiff(const uint8_t* old, size_t oldsize, const uint8_t* _new, size_t newsize,
14+
std::vector<uint8_t>& out_codeBuf) {
15+
const int myBestSingleMatchScore = 3;
16+
const size_t myBestStepMemSize = kDefaultStepMemSize;
17+
const size_t myBestDictSize = (1 << 20) * 8; // 固定 8MB,与 v1.0.6 一致
18+
19+
hpatch_TDecompress* decompressPlugin = &lzma2DecompressPlugin;
20+
TCompressPlugin_lzma2 compressPlugin = lzma2CompressPlugin;
21+
compressPlugin.compress_level = 9;
22+
compressPlugin.dict_size = myBestDictSize;
23+
compressPlugin.thread_num = 1;
24+
25+
create_single_compressed_diff(_new, _new + newsize, old, old + oldsize, out_codeBuf, 0,
26+
&compressPlugin.base, myBestSingleMatchScore, myBestStepMemSize);
27+
28+
if (!check_single_compressed_diff(_new, _new + newsize, old, old + oldsize, out_codeBuf.data(),
29+
out_codeBuf.data() + out_codeBuf.size(), decompressPlugin)) {
30+
throw std::runtime_error("check_single_compressed_diff() failed, diff code error!");
31+
}
32+
}

0 commit comments

Comments
 (0)