diff options
Diffstat (limited to 'xdelta3/xdelta3.c')
-rw-r--r-- | xdelta3/xdelta3.c | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/xdelta3/xdelta3.c b/xdelta3/xdelta3.c index 8c14ef2..5b325b3 100644 --- a/xdelta3/xdelta3.c +++ b/xdelta3/xdelta3.c | |||
@@ -332,12 +332,14 @@ typedef enum { | |||
332 | 332 | ||
333 | typedef enum { | 333 | typedef enum { |
334 | VCD_DJW_ID = 1, | 334 | VCD_DJW_ID = 1, |
335 | VCD_FGK_ID = 16, /* !!!Note: these are not a standard IANA-allocated ID!!! */ | 335 | VCD_FGK_ID = 16, /* Note: these are not standard IANA-allocated IDs! */ |
336 | } xd3_secondary_ids; | 336 | } xd3_secondary_ids; |
337 | 337 | ||
338 | typedef enum { | 338 | typedef enum { |
339 | SEC_NOFLAGS = 0, | 339 | SEC_NOFLAGS = 0, |
340 | SEC_COUNT_FREQS = (1 << 0), /* Note: Not implemented: eliminate 1st Huffman pass. */ | 340 | |
341 | /* Note: SEC_COUNT_FREQS Not implemented (to eliminate 1st Huffman pass) */ | ||
342 | SEC_COUNT_FREQS = (1 << 0), | ||
341 | } xd3_secondary_flags; | 343 | } xd3_secondary_flags; |
342 | 344 | ||
343 | typedef enum { | 345 | typedef enum { |
@@ -561,12 +563,13 @@ static void xd3_verify_small_state (xd3_stream *stream, | |||
561 | #endif /* XD3_DEBUG */ | 563 | #endif /* XD3_DEBUG */ |
562 | #endif /* XD3_ENCODER */ | 564 | #endif /* XD3_ENCODER */ |
563 | 565 | ||
564 | static int xd3_decode_allocate (xd3_stream *stream, usize_t size, | 566 | static int xd3_decode_allocate (xd3_stream *stream, usize_t size, |
565 | uint8_t **copied1, usize_t *alloc1); | 567 | uint8_t **copied1, usize_t *alloc1); |
566 | 568 | ||
567 | static void xd3_compute_code_table_string (const xd3_dinst *code_table, uint8_t *str); | 569 | static void xd3_compute_code_table_string (const xd3_dinst *code_table, |
568 | static void* xd3_alloc (xd3_stream *stream, usize_t elts, usize_t size); | 570 | uint8_t *str); |
569 | static void xd3_free (xd3_stream *stream, void *ptr); | 571 | static void* xd3_alloc (xd3_stream *stream, usize_t elts, usize_t size); |
572 | static void xd3_free (xd3_stream *stream, void *ptr); | ||
570 | 573 | ||
571 | static int xd3_read_uint32_t (xd3_stream *stream, const uint8_t **inpp, | 574 | static int xd3_read_uint32_t (xd3_stream *stream, const uint8_t **inpp, |
572 | const uint8_t *max, uint32_t *valp); | 575 | const uint8_t *max, uint32_t *valp); |
@@ -1745,7 +1748,7 @@ xd3_emit_bytes (xd3_stream *stream, | |||
1745 | if (PART & OFLOW) \ | 1748 | if (PART & OFLOW) \ |
1746 | { \ | 1749 | { \ |
1747 | stream->msg = "overflow in decode_integer"; \ | 1750 | stream->msg = "overflow in decode_integer"; \ |
1748 | return XD3_INVALID_INPUT; \ | 1751 | return XD3_INVALID_INPUT; \ |
1749 | } \ | 1752 | } \ |
1750 | \ | 1753 | \ |
1751 | PART = (PART << 7) | (next & 127); \ | 1754 | PART = (PART << 7) | (next & 127); \ |
@@ -1771,13 +1774,13 @@ xd3_emit_bytes (xd3_stream *stream, | |||
1771 | if (inp == max) \ | 1774 | if (inp == max) \ |
1772 | { \ | 1775 | { \ |
1773 | stream->msg = "end-of-input in read_integer"; \ | 1776 | stream->msg = "end-of-input in read_integer"; \ |
1774 | return XD3_INVALID_INPUT; \ | 1777 | return XD3_INVALID_INPUT; \ |
1775 | } \ | 1778 | } \ |
1776 | \ | 1779 | \ |
1777 | if (val & OFLOW) \ | 1780 | if (val & OFLOW) \ |
1778 | { \ | 1781 | { \ |
1779 | stream->msg = "overflow in read_intger"; \ | 1782 | stream->msg = "overflow in read_intger"; \ |
1780 | return XD3_INVALID_INPUT; \ | 1783 | return XD3_INVALID_INPUT; \ |
1781 | } \ | 1784 | } \ |
1782 | \ | 1785 | \ |
1783 | next = (*inp++); \ | 1786 | next = (*inp++); \ |
@@ -1888,10 +1891,12 @@ xd3_alloc_cache (xd3_stream *stream) | |||
1888 | { | 1891 | { |
1889 | if (((stream->acache.s_near > 0) && | 1892 | if (((stream->acache.s_near > 0) && |
1890 | (stream->acache.near_array = (usize_t*) | 1893 | (stream->acache.near_array = (usize_t*) |
1891 | xd3_alloc (stream, stream->acache.s_near, sizeof (usize_t))) == NULL) || | 1894 | xd3_alloc (stream, stream->acache.s_near, sizeof (usize_t))) |
1895 | == NULL) || | ||
1892 | ((stream->acache.s_same > 0) && | 1896 | ((stream->acache.s_same > 0) && |
1893 | (stream->acache.same_array = (usize_t*) | 1897 | (stream->acache.same_array = (usize_t*) |
1894 | xd3_alloc (stream, stream->acache.s_same * 256, sizeof (usize_t))) == NULL)) | 1898 | xd3_alloc (stream, stream->acache.s_same * 256, sizeof (usize_t))) |
1899 | == NULL)) | ||
1895 | { | 1900 | { |
1896 | return ENOMEM; | 1901 | return ENOMEM; |
1897 | } | 1902 | } |
@@ -1940,8 +1945,9 @@ xd3_encode_address (xd3_stream *stream, usize_t addr, usize_t here, uint8_t* mod | |||
1940 | 1945 | ||
1941 | #define SMALLEST_INT(x) do { if (((x) & ~127) == 0) { goto good; } } while (0) | 1946 | #define SMALLEST_INT(x) do { if (((x) & ~127) == 0) { goto good; } } while (0) |
1942 | 1947 | ||
1943 | /* Attempt to find the address mode that yields the smallest integer value for "d", the | 1948 | /* Attempt to find the address mode that yields the smallest integer value |
1944 | * encoded address value, thereby minimizing the encoded size of the address. */ | 1949 | * for "d", the encoded address value, thereby minimizing the encoded size |
1950 | * of the address. */ | ||
1945 | bestd = addr; | 1951 | bestd = addr; |
1946 | bestm = VCD_SELF; | 1952 | bestm = VCD_SELF; |
1947 | 1953 | ||
@@ -3359,8 +3365,10 @@ xd3_emit_hdr (xd3_stream *stream) | |||
3359 | if (vcd_source) | 3365 | if (vcd_source) |
3360 | { | 3366 | { |
3361 | /* or (vcd_target) { ... } */ | 3367 | /* or (vcd_target) { ... } */ |
3362 | if ((ret = xd3_emit_size (stream, & HDR_TAIL (stream), stream->src->srclen)) || | 3368 | if ((ret = xd3_emit_size (stream, & HDR_TAIL (stream), |
3363 | (ret = xd3_emit_offset (stream, & HDR_TAIL (stream), stream->src->srcbase))) { return ret; } | 3369 | stream->src->srclen)) || |
3370 | (ret = xd3_emit_offset (stream, & HDR_TAIL (stream), | ||
3371 | stream->src->srcbase))) { return ret; } | ||
3364 | } | 3372 | } |
3365 | 3373 | ||
3366 | tgt_len = stream->avail_in; | 3374 | tgt_len = stream->avail_in; |