"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "xdelta3-decode.h" between
xdelta3-3.0.11.tar.gz and xdelta3-3.1.0.tar.gz

About: xdelta is a tool and library for differential compression (supports VCDIFF encoding and decoding). Beta version.

xdelta3-decode.h  (xdelta3-3.0.11):xdelta3-decode.h  (xdelta3-3.1.0)
skipping to change at line 165 skipping to change at line 165
return 0; return 0;
} }
static int static int
xd3_decode_allocate (xd3_stream *stream, xd3_decode_allocate (xd3_stream *stream,
usize_t size, usize_t size,
uint8_t **buf_ptr, uint8_t **buf_ptr,
usize_t *buf_alloc) usize_t *buf_alloc)
{ {
IF_DEBUG2 (DP(RINT "[xd3_decode_allocate] size %u alloc %u\n", IF_DEBUG2 (DP(RINT "[xd3_decode_allocate] size %"W"u alloc %"W"u\n",
size, *buf_alloc)); size, *buf_alloc));
if (*buf_ptr != NULL && *buf_alloc < size) if (*buf_ptr != NULL && *buf_alloc < size)
{ {
xd3_free (stream, *buf_ptr); xd3_free (stream, *buf_ptr);
*buf_ptr = NULL; *buf_ptr = NULL;
} }
if (*buf_ptr == NULL) if (*buf_ptr == NULL)
{ {
skipping to change at line 210 skipping to change at line 210
if (stream->avail_in == 0) if (stream->avail_in == 0)
{ {
return XD3_INPUT; return XD3_INPUT;
} }
if ((copy == 0) && (section->pos == 0)) if ((copy == 0) && (section->pos == 0))
{ {
/* No allocation/copy needed */ /* No allocation/copy needed */
section->buf = stream->next_in; section->buf = stream->next_in;
sect_take = section->size; sect_take = section->size;
IF_DEBUG1 (DP(RINT "[xd3_decode_section] zerocopy %u @ %u avail %u\n", IF_DEBUG1 (DP(RINT "[xd3_decode_section] zerocopy %"W"u @ %"W"u avail % "W"u\n",
sect_take, section->pos, stream->avail_in)); sect_take, section->pos, stream->avail_in));
} }
else else
{ {
usize_t sect_need = section->size - section->pos; usize_t sect_need = section->size - section->pos;
/* Allocate and copy */ /* Allocate and copy */
sect_take = xd3_min (sect_need, stream->avail_in); sect_take = xd3_min (sect_need, stream->avail_in);
if (section->pos == 0) if (section->pos == 0)
skipping to change at line 235 skipping to change at line 235
section->size, section->size,
& section->copied1, & section->copied1,
& section->alloc1))) & section->alloc1)))
{ {
return ret; return ret;
} }
section->buf = section->copied1; section->buf = section->copied1;
} }
IF_DEBUG2 (DP(RINT "[xd3_decode_section] take %u @ %u [need %u] avail % u\n", IF_DEBUG2 (DP(RINT "[xd3_decode_section] take %"W"u @ %"W"u [need %"W"u ] avail %"W"u\n",
sect_take, section->pos, sect_need, stream->avail_in)); sect_take, section->pos, sect_need, stream->avail_in));
XD3_ASSERT (section->pos + sect_take <= section->alloc1); XD3_ASSERT (section->pos + sect_take <= section->alloc1);
memcpy (section->copied1 + section->pos, memcpy (section->copied1 + section->pos,
stream->next_in, stream->next_in,
sect_take); sect_take);
} }
section->pos += sect_take; section->pos += sect_take;
stream->dec_winbytes += sect_take; stream->dec_winbytes += sect_take;
DECODE_INPUT (sect_take); DECODE_INPUT (sect_take);
} }
if (section->pos < section->size) if (section->pos < section->size)
{ {
IF_DEBUG1 (DP(RINT "[xd3_decode_section] further input required %u\n", sec IF_DEBUG1 (DP(RINT "[xd3_decode_section] further input required %"W"u\n",
tion->size - section->pos)); section->size - section->pos));
stream->msg = "further input required"; stream->msg = "further input required";
return XD3_INPUT; return XD3_INPUT;
} }
XD3_ASSERT (section->pos == section->size); XD3_ASSERT (section->pos == section->size);
stream->dec_state = nstate; stream->dec_state = nstate;
section->buf_max = section->buf + section->size; section->buf_max = section->buf + section->size;
section->pos = 0; section->pos = 0;
return 0; return 0;
skipping to change at line 291 skipping to change at line 292
& inst->size))) & inst->size)))
{ {
return XD3_INVALID_INPUT; return XD3_INVALID_INPUT;
} }
/* For copy instructions, read address. */ /* For copy instructions, read address. */
if (inst->type >= XD3_CPY) if (inst->type >= XD3_CPY)
{ {
IF_DEBUG2 ({ IF_DEBUG2 ({
static int cnt = 0; static int cnt = 0;
XPR(NT "DECODE:%u: COPY at %"Q"u (winoffset %u) size %u winaddr %u\n", XPR(NT "DECODE:%u: COPY at %"Q"u (winoffset %"W"u) "
cnt++, "size %"W"u winaddr %"W"u\n",
stream->total_out + (stream->dec_position - cnt++,
stream->dec_cpylen), stream->total_out + (stream->dec_position -
(stream->dec_position - stream->dec_cpylen), stream->dec_cpylen),
inst->size, (stream->dec_position - stream->dec_cpylen),
inst->addr); inst->size,
inst->addr);
}); });
if ((ret = xd3_decode_address (stream, if ((ret = xd3_decode_address (stream,
stream->dec_position, stream->dec_position,
inst->type - XD3_CPY, inst->type - XD3_CPY,
& stream->addr_sect.buf, & stream->addr_sect.buf,
stream->addr_sect.buf_max, stream->addr_sect.buf_max,
& inst->addr))) & inst->addr)))
{ {
return ret; return ret;
skipping to change at line 332 skipping to change at line 334
stream->msg = "size too large"; stream->msg = "size too large";
return XD3_INVALID_INPUT; return XD3_INVALID_INPUT;
} }
} }
else else
{ {
IF_DEBUG2 ({ IF_DEBUG2 ({
if (inst->type == XD3_ADD) if (inst->type == XD3_ADD)
{ {
static int cnt; static int cnt;
XPR(NT "DECODE:%d: ADD at %"Q"u (winoffset %u) size %u\n", XPR(NT "DECODE:%d: ADD at %"Q"u (winoffset %"W"u) size %"W"u\n",
cnt++, cnt++,
(stream->total_out + stream->dec_position - stream->dec_cpylen), (stream->total_out + stream->dec_position - stream->dec_cpylen),
stream->dec_position - stream->dec_cpylen, stream->dec_position - stream->dec_cpylen,
inst->size); inst->size);
} }
else else
{ {
static int cnt; static int cnt;
XD3_ASSERT (inst->type == XD3_RUN); XD3_ASSERT (inst->type == XD3_RUN);
XPR(NT "DECODE:%d: RUN at %"Q"u (winoffset %u) size %u\n", XPR(NT "DECODE:%d: RUN at %"Q"u (winoffset %"W"u) size %"W"u\n",
cnt++, cnt++,
stream->total_out + stream->dec_position - stream->dec_cpylen, stream->total_out + stream->dec_position - stream->dec_cpylen,
stream->dec_position - stream->dec_cpylen, stream->dec_position - stream->dec_cpylen,
inst->size); inst->size);
} }
}); });
} }
/* Check: The instruction will not overflow the output buffer. */ /* Check: The instruction will not overflow the output buffer. */
if (stream->dec_position + inst->size > stream->dec_maxpos) if (stream->dec_position + inst->size > stream->dec_maxpos)
skipping to change at line 529 skipping to change at line 531
} }
src = source->curblk + blkoff; src = source->curblk + blkoff;
/* This block is either full, or a partial block that /* This block is either full, or a partial block that
* must contain enough bytes. */ * must contain enough bytes. */
if ((source->onblk != blksize) && if ((source->onblk != blksize) &&
(blkoff + take > source->onblk)) (blkoff + take > source->onblk))
{ {
IF_DEBUG1 (XPR(NT "[srcfile] short at blkno %"Q"u onblk " IF_DEBUG1 (XPR(NT "[srcfile] short at blkno %"Q"u onblk "
"%u blksize %u blkoff %u take %u\n", "%"W"u blksize %"W"u blkoff %"W"u take %"W"u\n ",
block, block,
source->onblk, source->onblk,
blksize, blksize,
blkoff, blkoff,
take)); take));
stream->msg = "source file too short"; stream->msg = "source file too short";
return XD3_INVALID_INPUT; return XD3_INVALID_INPUT;
} }
XD3_ASSERT (blkoff != blksize); XD3_ASSERT (blkoff != blksize);
skipping to change at line 774 skipping to change at line 776
{ {
if ((ret = xd3_decode_output_halfinst (stream, & stream->dec_current2)) ) if ((ret = xd3_decode_output_halfinst (stream, & stream->dec_current2)) )
{ {
return ret; return ret;
} }
} }
} }
if (stream->avail_out != stream->dec_tgtlen) if (stream->avail_out != stream->dec_tgtlen)
{ {
IF_DEBUG2 (DP(RINT "AVAIL_OUT(%d) != DEC_TGTLEN(%d)\n", IF_DEBUG2 (DP(RINT "AVAIL_OUT(%"W"u) != DEC_TGTLEN(%"W"u)\n",
stream->avail_out, stream->dec_tgtlen)); stream->avail_out, stream->dec_tgtlen));
stream->msg = "wrong window length"; stream->msg = "wrong window length";
return XD3_INVALID_INPUT; return XD3_INVALID_INPUT;
} }
if (stream->data_sect.buf != stream->data_sect.buf_max) if (stream->data_sect.buf != stream->data_sect.buf_max)
{ {
stream->msg = "extra data section"; stream->msg = "extra data section";
return XD3_INVALID_INPUT; return XD3_INVALID_INPUT;
} }
skipping to change at line 1028 skipping to change at line 1030
DEC_CPYOFF); DEC_CPYOFF);
/* Set the initial, logical decoder position (HERE address) in /* Set the initial, logical decoder position (HERE address) in
* dec_position. This is set to just after the source/copy * dec_position. This is set to just after the source/copy
* window, as we are just about to output the first byte of * window, as we are just about to output the first byte of
* target window. */ * target window. */
stream->dec_position = stream->dec_cpylen; stream->dec_position = stream->dec_cpylen;
case DEC_CPYOFF: case DEC_CPYOFF:
/* Copy window offset: only if VCD_SOURCE or VCD_TARGET is set */ /* Copy window offset: only if VCD_SOURCE or VCD_TARGET is set */
OFFSET_CASE(SRCORTGT (stream->dec_win_ind), stream->dec_cpyoff, OFFSET_CASE(SRCORTGT (stream->dec_win_ind), stream->dec_cpyoff,
DEC_ENCLEN); DEC_ENCLEN);
/* Copy offset and copy length may not overflow. */ /* Copy offset and copy length may not overflow. */
if (XOFF_T_OVERFLOW (stream->dec_cpyoff, stream->dec_cpylen)) if (XOFF_T_OVERFLOW (stream->dec_cpyoff, stream->dec_cpylen))
{ {
stream->msg = "decoder copy window overflows a file offset"; stream->msg = "decoder copy window overflows a file offset";
return XD3_INVALID_INPUT; return XD3_INVALID_INPUT;
} }
/* Check copy window bounds: VCD_TARGET window may not exceed /* Check copy window bounds: VCD_TARGET window may not exceed
current position. */ current position. */
if ((stream->dec_win_ind & VCD_TARGET) && if ((stream->dec_win_ind & VCD_TARGET) &&
(stream->dec_cpyoff + (xoff_t) stream->dec_cpylen > (stream->dec_cpyoff + stream->dec_cpylen >
stream->dec_winstart)) stream->dec_winstart))
{ {
stream->msg = "VCD_TARGET window out of bounds"; stream->msg = "VCD_TARGET window out of bounds";
return XD3_INVALID_INPUT; return XD3_INVALID_INPUT;
} }
case DEC_ENCLEN: case DEC_ENCLEN:
/* Length of the delta encoding */ /* Length of the delta encoding */
SIZE_CASE(1, stream->dec_enclen, DEC_TGTLEN); SIZE_CASE(1, stream->dec_enclen, DEC_TGTLEN);
case DEC_TGTLEN: case DEC_TGTLEN:
skipping to change at line 1171 skipping to change at line 1172
return XD3_INVALID_INPUT; return XD3_INVALID_INPUT;
} }
xd3_blksize_div(stream->dec_cpyoff, src, xd3_blksize_div(stream->dec_cpyoff, src,
&src->cpyoff_blocks, &src->cpyoff_blocks,
&src->cpyoff_blkoff); &src->cpyoff_blkoff);
IF_DEBUG2(DP(RINT IF_DEBUG2(DP(RINT
"[decode_cpyoff] %"Q"u " "[decode_cpyoff] %"Q"u "
"cpyblkno %"Q"u " "cpyblkno %"Q"u "
"cpyblkoff %u " "cpyblkoff %"W"u "
"blksize %u\n", "blksize %"W"u\n",
stream->dec_cpyoff, stream->dec_cpyoff,
src->cpyoff_blocks, src->cpyoff_blocks,
src->cpyoff_blkoff, src->cpyoff_blkoff,
src->blksize)); src->blksize));
} }
/* xd3_decode_emit returns XD3_OUTPUT on every success. */ /* xd3_decode_emit returns XD3_OUTPUT on every success. */
if ((ret = xd3_decode_emit (stream)) == XD3_OUTPUT) if ((ret = xd3_decode_emit (stream)) == XD3_OUTPUT)
{ {
stream->total_out += (xoff_t) stream->avail_out; stream->total_out += stream->avail_out;
} }
return ret; return ret;
case DEC_FINISH: case DEC_FINISH:
{ {
if (stream->dec_win_ind & VCD_TARGET) if (stream->dec_win_ind & VCD_TARGET)
{ {
if (stream->dec_lastwin == NULL) if (stream->dec_lastwin == NULL)
{ {
 End of changes. 13 change blocks. 
21 lines changed or deleted 21 lines changed or added

Home  |  About  |  All  |  Newest  |  Fossies Dox  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTPS