summaryrefslogtreecommitdiff
path: root/xdelta3/xdelta3.c
diff options
context:
space:
mode:
Diffstat (limited to 'xdelta3/xdelta3.c')
-rw-r--r--xdelta3/xdelta3.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/xdelta3/xdelta3.c b/xdelta3/xdelta3.c
index c2061a0..bdf02af 100644
--- a/xdelta3/xdelta3.c
+++ b/xdelta3/xdelta3.c
@@ -2103,7 +2103,7 @@ xd3_alloc (xd3_stream *stream,
2103 if (a != NULL) 2103 if (a != NULL)
2104 { 2104 {
2105 IF_DEBUG (stream->alloc_cnt += 1); 2105 IF_DEBUG (stream->alloc_cnt += 1);
2106 IF_DEBUG1 (DP(RINT "[stream %p malloc] size %u ptr %p\n", 2106 IF_DEBUG2 (DP(RINT "[stream %p malloc] size %u ptr %p\n",
2107 stream, elts * size, a)); 2107 stream, elts * size, a));
2108 } 2108 }
2109 else 2109 else
@@ -2122,7 +2122,7 @@ xd3_free (xd3_stream *stream,
2122 { 2122 {
2123 IF_DEBUG (stream->free_cnt += 1); 2123 IF_DEBUG (stream->free_cnt += 1);
2124 XD3_ASSERT (stream->free_cnt <= stream->alloc_cnt); 2124 XD3_ASSERT (stream->free_cnt <= stream->alloc_cnt);
2125 IF_DEBUG1 (DP(RINT "[stream %p free] %p\n", 2125 IF_DEBUG2 (DP(RINT "[stream %p free] %p\n",
2126 stream, ptr)); 2126 stream, ptr));
2127 stream->free (stream->opaque, ptr); 2127 stream->free (stream->opaque, ptr);
2128 } 2128 }
@@ -3228,7 +3228,7 @@ xd3_emit_single (xd3_stream *stream, xd3_rinst *single, usize_t code)
3228 3228
3229 IF_DEBUG1 (DP(RINT "[emit1] %u %s (%u) code %u\n", 3229 IF_DEBUG1 (DP(RINT "[emit1] %u %s (%u) code %u\n",
3230 single->pos, 3230 single->pos,
3231 xd3_rtype_to_string (single->type, 0), 3231 xd3_rtype_to_string ((xd3_rtype) single->type, 0),
3232 single->size, 3232 single->size,
3233 code)); 3233 code));
3234 3234
@@ -3266,9 +3266,9 @@ xd3_emit_double (xd3_stream *stream, xd3_rinst *first,
3266 3266
3267 IF_DEBUG1 (DP(RINT "[emit2]: %u %s (%u) %s (%u) code %u\n", 3267 IF_DEBUG1 (DP(RINT "[emit2]: %u %s (%u) %s (%u) code %u\n",
3268 first->pos, 3268 first->pos,
3269 xd3_rtype_to_string (first->type, 0), 3269 xd3_rtype_to_string ((xd3_rtype) first->type, 0),
3270 first->size, 3270 first->size,
3271 xd3_rtype_to_string (second->type, 0), 3271 xd3_rtype_to_string ((xd3_rtype) second->type, 0),
3272 second->size, 3272 second->size,
3273 code)); 3273 code));
3274 3274
@@ -4329,10 +4329,14 @@ xd3_source_match_setup (xd3_stream *stream, xoff_t srcpos)
4329 stream->match_back = 0; 4329 stream->match_back = 0;
4330 stream->match_fwd = 0; 4330 stream->match_fwd = 0;
4331 4331
4332 /* This avoids a loop. TODO: if ever duplicates are added to the 4332 /* This avoids a non-blocking endless loop caused by scanning
4333 * source hash table, this logic won't suffice to avoid loops. 4333 * backwards across a block boundary, only to find not enough
4334 * TODO: how can you test this in a unittest? Need to search for 4334 * matching bytes to beat the current min_match due to a better lazy
4335 * hash collisions, I suppose. */ 4335 * target match: the re-entry to xd3_string_match() repeats the same
4336 * long match because the input position hasn't changed. TODO: if
4337 * ever duplicates are added to the source hash table, this logic
4338 * won't suffice to avoid loops. See testing/regtest.cc's
4339 * TestNonBlockingProgress test! */
4336 if (srcpos != 0 && srcpos == stream->match_last_srcpos) 4340 if (srcpos != 0 && srcpos == stream->match_last_srcpos)
4337 { 4341 {
4338 goto bad; 4342 goto bad;