diff options
author | josh.macdonald <jmacd@users.noreply.github.com> | 2008-04-19 04:23:41 +0000 |
---|---|---|
committer | josh.macdonald <jmacd@users.noreply.github.com> | 2008-04-19 04:23:41 +0000 |
commit | bbe3286bc10894036a877cb7186fe033b9872520 (patch) | |
tree | 3d5856601f4c96a78fa2c37eebf81ec3d8a8b934 | |
parent | 38c56fe9beed20615b5570e2d833bf0827b772f7 (diff) |
Cleanup of previous. New xd3_merge_input_output used in both
main_merge_arguments and main_merge_output.
-rw-r--r-- | xdelta3/xdelta3-main.h | 28 | ||||
-rw-r--r-- | xdelta3/xdelta3-merge.h | 34 |
2 files changed, 41 insertions, 21 deletions
diff --git a/xdelta3/xdelta3-main.h b/xdelta3/xdelta3-main.h index acb0ac0..91c9884 100644 --- a/xdelta3/xdelta3-main.h +++ b/xdelta3/xdelta3-main.h | |||
@@ -1692,22 +1692,13 @@ main_merge_arguments (main_merge_list* merges) | |||
1692 | } | 1692 | } |
1693 | else | 1693 | else |
1694 | { | 1694 | { |
1695 | xd3_stream tmp_stream; | 1695 | /* Merge the recode_stream with merge_input. */ |
1696 | memset (& tmp_stream, 0, sizeof (tmp_stream)); | 1696 | ret = xd3_merge_input_output (recode_stream, |
1697 | if ((ret = xd3_config_stream (& tmp_stream, NULL)) || | 1697 | & merge_input.whole_target); |
1698 | (ret = xd3_whole_state_init (& tmp_stream)) || | ||
1699 | (ret = xd3_merge_inputs (& tmp_stream, | ||
1700 | & merge_input.whole_target, | ||
1701 | & recode_stream->whole_target))) | ||
1702 | { | ||
1703 | XPR(NT XD3_LIB_ERRMSG (&tmp_stream, ret)); | ||
1704 | } | ||
1705 | 1698 | ||
1706 | /* the output is in tmp_stream.whole_state, swap into input */ | 1699 | /* Save the next merge source in merge_input. */ |
1707 | xd3_swap_whole_state (& merge_input.whole_target, | 1700 | xd3_swap_whole_state (& recode_stream->whole_target, |
1708 | & tmp_stream.whole_target); | 1701 | & merge_input.whole_target); |
1709 | /* total allocation counts are preserved */ | ||
1710 | xd3_free_stream (& tmp_stream); | ||
1711 | } | 1702 | } |
1712 | } | 1703 | } |
1713 | 1704 | ||
@@ -1792,10 +1783,9 @@ main_merge_output (xd3_stream *stream, main_file *ofile) | |||
1792 | 1783 | ||
1793 | /* merge_stream is set if there were arguments. this stream's input | 1784 | /* merge_stream is set if there were arguments. this stream's input |
1794 | * needs to be applied to the merge_stream source. */ | 1785 | * needs to be applied to the merge_stream source. */ |
1795 | if (merge_stream != NULL && | 1786 | if ((merge_stream != NULL) && |
1796 | (ret = xd3_merge_inputs (stream, | 1787 | (ret = xd3_merge_input_output (stream, |
1797 | & merge_stream->whole_target, | 1788 | & merge_stream->whole_target))) |
1798 | & stream->whole_target))) | ||
1799 | { | 1789 | { |
1800 | XPR(NT XD3_LIB_ERRMSG (stream, ret)); | 1790 | XPR(NT XD3_LIB_ERRMSG (stream, ret)); |
1801 | return ret; | 1791 | return ret; |
diff --git a/xdelta3/xdelta3-merge.h b/xdelta3/xdelta3-merge.h index 2e54cb5..a7b3329 100644 --- a/xdelta3/xdelta3-merge.h +++ b/xdelta3/xdelta3-merge.h | |||
@@ -19,6 +19,10 @@ | |||
19 | #ifndef _XDELTA3_MERGE_H_ | 19 | #ifndef _XDELTA3_MERGE_H_ |
20 | #define _XDELTA3_MERGE_H_ | 20 | #define _XDELTA3_MERGE_H_ |
21 | 21 | ||
22 | int xd3_merge_inputs (xd3_stream *stream, | ||
23 | xd3_whole_state *source, | ||
24 | xd3_whole_state *input); | ||
25 | |||
22 | static int | 26 | static int |
23 | xd3_whole_state_init (xd3_stream *stream) | 27 | xd3_whole_state_init (xd3_stream *stream) |
24 | { | 28 | { |
@@ -190,13 +194,39 @@ xd3_whole_append_window (xd3_stream *stream) | |||
190 | return 0; | 194 | return 0; |
191 | } | 195 | } |
192 | 196 | ||
197 | /* xd3_merge_input_output applies *source to *stream, returns the | ||
198 | * result in stream. */ | ||
199 | int xd3_merge_input_output (xd3_stream *stream, | ||
200 | xd3_whole_state *source) | ||
201 | { | ||
202 | int ret; | ||
203 | xd3_stream tmp_stream; | ||
204 | memset (& tmp_stream, 0, sizeof (tmp_stream)); | ||
205 | if ((ret = xd3_config_stream (& tmp_stream, NULL)) || | ||
206 | (ret = xd3_whole_state_init (& tmp_stream)) || | ||
207 | (ret = xd3_merge_inputs (& tmp_stream, | ||
208 | source, | ||
209 | & stream->whole_target))) | ||
210 | { | ||
211 | XPR(NT XD3_LIB_ERRMSG (&tmp_stream, ret)); | ||
212 | return ret; | ||
213 | } | ||
214 | |||
215 | /* the output is in tmp_stream.whole_state, swap into input */ | ||
216 | xd3_swap_whole_state (& stream->whole_target, | ||
217 | & tmp_stream.whole_target); | ||
218 | /* total allocation counts are preserved */ | ||
219 | xd3_free_stream (& tmp_stream); | ||
220 | return 0; | ||
221 | } | ||
222 | |||
193 | /* xd3_merge_inputs() applies *input to *source, returns its result in | 223 | /* xd3_merge_inputs() applies *input to *source, returns its result in |
194 | * stream. */ | 224 | * stream. In certain cases, input == stream->whole_target. */ |
195 | int xd3_merge_inputs (xd3_stream *stream, | 225 | int xd3_merge_inputs (xd3_stream *stream, |
196 | xd3_whole_state *source, | 226 | xd3_whole_state *source, |
197 | xd3_whole_state *input) | 227 | xd3_whole_state *input) |
198 | { | 228 | { |
199 | DP(RINT "Merge inputs!\n"); | 229 | |
200 | 230 | ||
201 | xd3_swap_whole_state (&stream->whole_target, input); | 231 | xd3_swap_whole_state (&stream->whole_target, input); |
202 | 232 | ||