sisong / HDiffPatch

a C\C++ library and command-line tools for Diff & Patch between binary files or directories(folder); cross-platform; runs fast; create small delta/differential; support large files and limit memory requires when diff & patch.
Other
1.56k stars 287 forks source link

Patching in chunks with a single allocated buffer #325

Closed eitanmi closed 1 year ago

eitanmi commented 1 year ago

Hi, Suppose I have the diff and the old data, and I'd like to read them chunk by chunk and slowly build the new data in memory. Can this be done using a fixed memory buffer?

Something like :

while (not at end of stream) { old_data = read(old_file) diff_data = read(diff_file)

// Chunk by chunk accumulate new data somehow... */ new_data += patch(old_data , diff_data , plugin);

}

sisong commented 1 year ago

now, HDiffPatch no patch API like "push".
But you can refer to the description of the patch_single_stream() function, which may be able to meet your needs.
For example, if you want to process new_data sequentially, you can use the out_newData->write to got them.