xdelta3-merge.h (xdelta3-3.0.10) | : | xdelta3-merge.h (xdelta3-3.0.11) | ||
---|---|---|---|---|
skipping to change at line 495 | skipping to change at line 495 | |||
stream->whole_target.addslen += this_take; | stream->whole_target.addslen += this_take; | |||
break; | break; | |||
default: | default: | |||
if (sinst->mode != 0) | if (sinst->mode != 0) | |||
{ | { | |||
minst->mode = sinst->mode; | minst->mode = sinst->mode; | |||
minst->addr = sinst->addr + sinst_offset; | minst->addr = sinst->addr + sinst_offset; | |||
} | } | |||
else | else | |||
{ | { | |||
// TODO: this is slow because of the recursion, which | // Note: A better implementation will construct the | |||
// could reach a depth equal to the number of target | // mapping of output ranges, starting from the input | |||
// copies, and this is compression-inefficient because | // range, applying deltas in forward order, using an | |||
// it can produce duplicate adds. | // interval tree. This code uses recursion to construct | |||
// each copied range, recursively (using binary search | ||||
// in xd3_merge_find_position). | ||||
// | ||||
// TODO: This code can cause stack overflow. Fix as | ||||
// described above. | ||||
xd3_winst tinst; | xd3_winst tinst; | |||
tinst.type = XD3_CPY; | tinst.type = XD3_CPY; | |||
tinst.mode = iinst.mode; | tinst.mode = iinst.mode; | |||
tinst.addr = sinst->addr + sinst_offset; | tinst.addr = sinst->addr + sinst_offset; | |||
tinst.size = this_take; | tinst.size = this_take; | |||
tinst.position = iinst.position; | tinst.position = iinst.position; | |||
// The instruction allocated in this frame will not be used. | // The instruction allocated in this frame will not be used. | |||
stream->whole_target.instlen -= 1; | stream->whole_target.instlen -= 1; | |||
skipping to change at line 558 | skipping to change at line 563 | |||
switch (iinst->type) | switch (iinst->type) | |||
{ | { | |||
case XD3_RUN: | case XD3_RUN: | |||
ret = xd3_merge_run (stream, input, iinst); | ret = xd3_merge_run (stream, input, iinst); | |||
break; | break; | |||
case XD3_ADD: | case XD3_ADD: | |||
ret = xd3_merge_add (stream, input, iinst); | ret = xd3_merge_add (stream, input, iinst); | |||
break; | break; | |||
default: | default: | |||
/* TODO: VCD_TARGET support is completely untested all | if (iinst->mode == 0) | |||
* throughout. */ | ||||
if (iinst->mode == 0 || iinst->mode == VCD_TARGET) | ||||
{ | { | |||
ret = xd3_merge_target_copy (stream, iinst); | ret = xd3_merge_target_copy (stream, iinst); | |||
} | } | |||
else if (iinst->mode == VCD_TARGET) | ||||
{ | ||||
ret = XD3_INVALID_INPUT; | ||||
} | ||||
else | else | |||
{ | { | |||
ret = xd3_merge_source_copy (stream, source, iinst); | ret = xd3_merge_source_copy (stream, source, iinst); | |||
} | } | |||
/* The whole_target.length is not updated in the xd3_merge*copy | /* The whole_target.length is not updated in the xd3_merge*copy | |||
* routine because of recursion in xd3_merge_source_copy. */ | * routine because of recursion in xd3_merge_source_copy. */ | |||
stream->whole_target.length += iinst->size; | stream->whole_target.length += iinst->size; | |||
break; | break; | |||
} | } | |||
End of changes. 3 change blocks. | ||||
7 lines changed or deleted | 14 lines changed or added |