Skip to content

Commit eedead3

Browse files
committed
test hdiff ok
1 parent ff3c1a1 commit eedead3

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

binding.gyp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
"HDiffPatch/libHDiffPatch/HDiff/private_diff/bytes_rle.cpp",
1111
"HDiffPatch/libHDiffPatch/HDiff/private_diff/suffix_string.cpp",
1212
"HDiffPatch/libHDiffPatch/HDiff/private_diff/compress_detect.cpp",
13-
"HDiffPatch/libHDiffPatch/HDiff/private_diff/limit_mem_diff/digest_matcher.cpp",
14-
"HDiffPatch/libHDiffPatch/HDiff/private_diff/limit_mem_diff/stream_serialize.cpp",
1513
"HDiffPatch/libHDiffPatch/HDiff/private_diff/libdivsufsort/divsufsort64.cpp",
1614
"HDiffPatch/libHDiffPatch/HDiff/private_diff/libdivsufsort/divsufsort.cpp",
15+
"HDiffPatch/libHDiffPatch/HDiff/private_diff/limit_mem_diff/digest_matcher.cpp",
16+
"HDiffPatch/libHDiffPatch/HDiff/private_diff/limit_mem_diff/stream_serialize.cpp",
1717
"HDiffPatch/libHDiffPatch/HDiff/private_diff/limit_mem_diff/adler_roll.cpp",
1818
"lzma/C/LzFind.c",
1919
"lzma/C/LzmaDec.c",

src/hdiff.cpp

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,36 @@
22
* Created by housisong on 2021.04.07.
33
*/
44
#include "hdiff.h"
5-
#include "HDiffPatch/libHDiffPatch/HDiff/diff.h"
5+
#include "../HDiffPatch/libHDiffPatch/HDiff/diff.h"
6+
#include <stdexcept> // for std::runtime_error
67

78
#define _CompressPlugin_lzma2
89
#define _IsNeedIncludeDefaultCompressHead 0
9-
#include "lzma/C/LzmaEnc.h"
10-
#include "lzma/C/Lzma2Enc.h"
11-
#include "lzma/C/MtCoder.h"
12-
#include "HDiffPatch/compress_plugin_demo.h"
10+
#include "../lzma/C/LzmaDec.h"
11+
#include "../lzma/C/Lzma2Dec.h"
12+
#include "../lzma/C/LzmaEnc.h"
13+
#include "../lzma/C/Lzma2Enc.h"
14+
#include "../lzma/C/MtCoder.h"
15+
#include "../HDiffPatch/compress_plugin_demo.h"
16+
#include "../HDiffPatch/decompress_plugin_demo.h"
1317

1418
void hdiff(const uint8_t* old,size_t oldsize,const uint8_t* _new,size_t newsize,
1519
std::vector<uint8_t>& out_codeBuf){
16-
const int myBestSingleMatchScore=3;
20+
const int myBestSingleMatchScore=3;
1721
const size_t myBestStepMemSize=kDefaultStepMemSize;
1822
const size_t myBestDictSize=(1<<20)*8; //8MB mem
1923

24+
hpatch_TDecompress* decompressPlugin=&lzma2DecompressPlugin;
2025
TCompressPlugin_lzma2 compressPlugin=lzma2CompressPlugin;
2126
compressPlugin.compress_level=9;
2227
compressPlugin.dict_size=myBestDictSize;
2328
compressPlugin.thread_num=1;
29+
2430
create_single_compressed_diff(_new,_new+newsize,old,old+oldsize,out_codeBuf,0,
2531
&compressPlugin.base,myBestSingleMatchScore,myBestStepMemSize);
32+
33+
if (!check_single_compressed_diff(_new,_new+newsize,old,old+oldsize,out_codeBuf.data(),
34+
out_codeBuf.data()+out_codeBuf.size(),decompressPlugin)){
35+
throw std::runtime_error("create_single_compressed_diff() out data error!");
36+
}
2637
}

src/hdiff.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include <stdint.h>
88
#include <vector>
99

10-
voif hdiff(const uint8_t* old,size_t oldsize,const uint8_t* _new,size_t newsize,
10+
void hdiff(const uint8_t* old,size_t oldsize,const uint8_t* _new,size_t newsize,
1111
std::vector<uint8_t>& out_codeBuf);
1212

1313
#endif

0 commit comments

Comments
 (0)