summaryrefslogtreecommitdiff
path: root/xdelta3/xdelta3.c
diff options
context:
space:
mode:
Diffstat (limited to 'xdelta3/xdelta3.c')
-rw-r--r--xdelta3/xdelta3.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/xdelta3/xdelta3.c b/xdelta3/xdelta3.c
index a789b16..23877b1 100644
--- a/xdelta3/xdelta3.c
+++ b/xdelta3/xdelta3.c
@@ -1261,19 +1261,17 @@ int xd3_compute_code_table_encoding (xd3_stream *in_stream,
1261{ 1261{
1262 /* Use DJW secondary compression if it is on by default. This saves 1262 /* Use DJW secondary compression if it is on by default. This saves
1263 * about 20 bytes. */ 1263 * about 20 bytes. */
1264 int flags = (SECONDARY_DJW ? XD3_SEC_DJW : 0) | XD3_COMPLEVEL_9 | XD3_ADLER32;
1265
1266 uint8_t dflt_string[CODE_TABLE_STRING_SIZE]; 1264 uint8_t dflt_string[CODE_TABLE_STRING_SIZE];
1267 uint8_t code_string[CODE_TABLE_STRING_SIZE]; 1265 uint8_t code_string[CODE_TABLE_STRING_SIZE];
1268 int ret; 1266
1269
1270 xd3_compute_code_table_string (xd3_rfc3284_code_table (), dflt_string); 1267 xd3_compute_code_table_string (xd3_rfc3284_code_table (), dflt_string);
1271 xd3_compute_code_table_string (code_table, code_string); 1268 xd3_compute_code_table_string (code_table, code_string);
1272 1269
1273 return xd3_encode_memory (code_string, CODE_TABLE_STRING_SIZE, 1270 return xd3_encode_memory (code_string, CODE_TABLE_STRING_SIZE,
1274 dflt_string, CODE_TABLE_STRING_SIZE, 1271 dflt_string, CODE_TABLE_STRING_SIZE,
1275 comp_string, comp_string_size, 1272 comp_string, comp_string_size,
1276 CODE_TABLE_VCDIFF_SIZE); 1273 CODE_TABLE_VCDIFF_SIZE,
1274 /* flags */ 0);
1277} 1275}
1278 1276
1279/* Compute a delta between alternate and rfc3284 tables. As soon as 1277/* Compute a delta between alternate and rfc3284 tables. As soon as
@@ -1364,7 +1362,9 @@ xd3_apply_table_string (xd3_stream *stream, const uint8_t *code_string)
1364 xd3_dinst *code_table; 1362 xd3_dinst *code_table;
1365 1363
1366 if ((code_table = stream->code_table_alloc = 1364 if ((code_table = stream->code_table_alloc =
1367 (xd3_dinst*) xd3_alloc (stream, sizeof (xd3_dinst), 256)) == NULL) 1365 (xd3_dinst*) xd3_alloc (stream,
1366 (usize_t) sizeof (xd3_dinst),
1367 256)) == NULL)
1368 { 1368 {
1369 return ENOMEM; 1369 return ENOMEM;
1370 } 1370 }
@@ -1638,7 +1638,7 @@ xd3_decode_bytes (xd3_stream *stream, uint8_t *buf, usize_t *pos, usize_t size)
1638 want = size - *pos; 1638 want = size - *pos;
1639 take = min (want, stream->avail_in); 1639 take = min (want, stream->avail_in);
1640 1640
1641 memcpy (buf + *pos, stream->next_in, take); 1641 memcpy (buf + *pos, stream->next_in, (size_t) take);
1642 1642
1643 DECODE_INPUT (take); 1643 DECODE_INPUT (take);
1644 (*pos) += take; 1644 (*pos) += take;
@@ -1698,7 +1698,7 @@ xd3_emit_bytes (xd3_stream *stream,
1698 1698
1699 take = min (output->avail - output->next, size); 1699 take = min (output->avail - output->next, size);
1700 1700
1701 memcpy (output->base + output->next, base, take); 1701 memcpy (output->base + output->next, base, (size_t) take);
1702 1702
1703 output->next += take; 1703 output->next += take;
1704 size -= take; 1704 size -= take;
@@ -1873,11 +1873,13 @@ xd3_alloc_cache (xd3_stream *stream)
1873 1873
1874 if (((stream->acache.s_near > 0) && 1874 if (((stream->acache.s_near > 0) &&
1875 (stream->acache.near_array = (usize_t*) 1875 (stream->acache.near_array = (usize_t*)
1876 xd3_alloc (stream, stream->acache.s_near, sizeof (usize_t))) 1876 xd3_alloc (stream, stream->acache.s_near,
1877 (usize_t) sizeof (usize_t)))
1877 == NULL) || 1878 == NULL) ||
1878 ((stream->acache.s_same > 0) && 1879 ((stream->acache.s_same > 0) &&
1879 (stream->acache.same_array = (usize_t*) 1880 (stream->acache.same_array = (usize_t*)
1880 xd3_alloc (stream, stream->acache.s_same * 256, sizeof (usize_t))) 1881 xd3_alloc (stream, stream->acache.s_same * 256,
1882 (usize_t) sizeof (usize_t)))
1881 == NULL)) 1883 == NULL))
1882 { 1884 {
1883 return ENOMEM; 1885 return ENOMEM;
@@ -2047,7 +2049,7 @@ xd3_decode_address (xd3_stream *stream, usize_t here,
2047static void* 2049static void*
2048__xd3_alloc_func (void* opaque, usize_t items, usize_t size) 2050__xd3_alloc_func (void* opaque, usize_t items, usize_t size)
2049{ 2051{
2050 return malloc (items * size); 2052 return malloc ((size_t) items * (size_t) size);
2051} 2053}
2052 2054
2053static void 2055static void
@@ -2101,7 +2103,7 @@ xd3_alloc0 (xd3_stream *stream,
2101 2103
2102 if (a != NULL) 2104 if (a != NULL)
2103 { 2105 {
2104 memset (a, 0, elts * size); 2106 memset (a, 0, (size_t) (elts * size));
2105 } 2107 }
2106 2108
2107 return a; 2109 return a;
@@ -2122,7 +2124,8 @@ xd3_alloc_output (xd3_stream *stream,
2122 else 2124 else
2123 { 2125 {
2124 if ((output = (xd3_output*) xd3_alloc (stream, 1, 2126 if ((output = (xd3_output*) xd3_alloc (stream, 1,
2125 sizeof (xd3_output))) == NULL) 2127 (usize_t) sizeof (xd3_output)))
2128 == NULL)
2126 { 2129 {
2127 return NULL; 2130 return NULL;
2128 } 2131 }