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
1418void 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}
0 commit comments