summaryrefslogtreecommitdiff
path: root/xdelta3/xdelta3-main.h
diff options
context:
space:
mode:
Diffstat (limited to 'xdelta3/xdelta3-main.h')
-rw-r--r--xdelta3/xdelta3-main.h50
1 files changed, 26 insertions, 24 deletions
diff --git a/xdelta3/xdelta3-main.h b/xdelta3/xdelta3-main.h
index 23133a3..5c02a75 100644
--- a/xdelta3/xdelta3-main.h
+++ b/xdelta3/xdelta3-main.h
@@ -227,7 +227,7 @@ struct _main_extcomp
227 227
228 const char *ident; 228 const char *ident;
229 const char *magic; 229 const char *magic;
230 int magic_size; 230 usize_t magic_size;
231 int flags; 231 int flags;
232}; 232};
233 233
@@ -300,7 +300,7 @@ static uint8_t* appheader_used = NULL;
300static uint8_t* main_bdata = NULL; 300static uint8_t* main_bdata = NULL;
301 301
302/* The LRU: obviously this is shared by all callers. */ 302/* The LRU: obviously this is shared by all callers. */
303static int lru_size = 0; 303static usize_t lru_size = 0;
304static main_blklru *lru = NULL; /* array of lru_size elts */ 304static main_blklru *lru = NULL; /* array of lru_size elts */
305static main_blklru_list lru_list; 305static main_blklru_list lru_list;
306static main_blklru_list lru_free; 306static main_blklru_list lru_free;
@@ -550,7 +550,7 @@ static char*
550main_format_bcnt (xoff_t r, char *buf) 550main_format_bcnt (xoff_t r, char *buf)
551{ 551{
552 static const char* fmts[] = { "B", "KB", "MB", "GB" }; 552 static const char* fmts[] = { "B", "KB", "MB", "GB" };
553 int i; 553 usize_t i;
554 554
555 for (i = 0; i < SIZEOF_ARRAY(fmts); i += 1) 555 for (i = 0; i < SIZEOF_ARRAY(fmts); i += 1)
556 { 556 {
@@ -977,7 +977,7 @@ main_file_seek (main_file *xfile, xoff_t pos)
977 if (fseek (xfile->file, pos, SEEK_SET) != 0) { ret = get_errno (); } 977 if (fseek (xfile->file, pos, SEEK_SET) != 0) { ret = get_errno (); }
978 978
979#elif XD3_POSIX 979#elif XD3_POSIX
980 if (lseek (xfile->file, pos, SEEK_SET) != pos) { ret = get_errno (); } 980 if ((xoff_t) lseek (xfile->file, pos, SEEK_SET) != pos) { ret = get_errno (); }
981 981
982#elif XD3_WIN32 982#elif XD3_WIN32
983 LARGE_INTEGER move, out; 983 LARGE_INTEGER move, out;
@@ -1725,10 +1725,10 @@ main_decompress_input_check (main_file *ifile,
1725 usize_t input_size, 1725 usize_t input_size,
1726 usize_t *nread) 1726 usize_t *nread)
1727{ 1727{
1728 int i;
1729 int ret; 1728 int ret;
1729 usize_t i;
1730 usize_t check_nread;
1730 uint8_t check_buf[XD3_ALLOCSIZE]; 1731 uint8_t check_buf[XD3_ALLOCSIZE];
1731 usize_t check_nread;
1732 1732
1733 if ((ret = main_file_read (ifile, check_buf, min (input_size, XD3_ALLOCSIZE), & check_nread, "input read failed"))) 1733 if ((ret = main_file_read (ifile, check_buf, min (input_size, XD3_ALLOCSIZE), & check_nread, "input read failed")))
1734 { 1734 {
@@ -1794,7 +1794,8 @@ main_decompress_source (main_file *sfile, xd3_source *source)
1794 1794
1795 /* Make a template for mkstmp() */ 1795 /* Make a template for mkstmp() */
1796 if (tmpdir == NULL) { tmpdir = "/tmp"; } 1796 if (tmpdir == NULL) { tmpdir = "/tmp"; }
1797 if ((tmpname = main_malloc (strlen (tmpdir) + sizeof (tmpl) + 1)) == NULL) { return ENOMEM; } 1797 if ((tmpname =
1798 (char*) main_malloc (strlen (tmpdir) + sizeof (tmpl) + 1)) == NULL) { return ENOMEM; }
1798 sprintf (tmpname, "%s%s", tmpdir, tmpl); 1799 sprintf (tmpname, "%s%s", tmpdir, tmpl);
1799 1800
1800 XD3_ASSERT (ext_tmpfile == NULL); 1801 XD3_ASSERT (ext_tmpfile == NULL);
@@ -1960,7 +1961,7 @@ main_recompress_output (main_file *ofile)
1960static const main_extcomp* 1961static const main_extcomp*
1961main_ident_compressor (const char *ident) 1962main_ident_compressor (const char *ident)
1962{ 1963{
1963 int i; 1964 usize_t i;
1964 1965
1965 for (i = 0; i < SIZEOF_ARRAY (extcomp_types); i += 1) 1966 for (i = 0; i < SIZEOF_ARRAY (extcomp_types); i += 1)
1966 { 1967 {
@@ -2059,7 +2060,7 @@ main_set_appheader (xd3_stream *stream, main_file *input, main_file *sfile)
2059 sname = scomp = ""; 2060 sname = scomp = "";
2060 } 2061 }
2061 2062
2062 if ((appheader_used = main_malloc (len)) == NULL) 2063 if ((appheader_used = (uint8_t*) main_malloc (len)) == NULL)
2063 { 2064 {
2064 return ENOMEM; 2065 return ENOMEM;
2065 } 2066 }
@@ -2103,7 +2104,7 @@ main_get_appheader_params (main_file *file, char **parsed, int output, const cha
2103 int dlen = last_slash - other->filename; 2104 int dlen = last_slash - other->filename;
2104 2105
2105 XD3_ASSERT(file->filename_copy == NULL); 2106 XD3_ASSERT(file->filename_copy == NULL);
2106 file->filename_copy = main_malloc(dlen + 2 + strlen(file->filename)); 2107 file->filename_copy = (char*) main_malloc(dlen + 2 + strlen(file->filename));
2107 2108
2108 strncpy(file->filename_copy, other->filename, dlen); 2109 strncpy(file->filename_copy, other->filename, dlen);
2109 file->filename_copy[dlen] = '/'; 2110 file->filename_copy[dlen] = '/';
@@ -2264,7 +2265,8 @@ main_open_output (xd3_stream *stream, main_file *ofile)
2264static int 2265static int
2265main_set_source (xd3_stream *stream, int cmd, main_file *sfile, xd3_source *source) 2266main_set_source (xd3_stream *stream, int cmd, main_file *sfile, xd3_source *source)
2266{ 2267{
2267 int ret = 0, i; 2268 int ret = 0;
2269 usize_t i;
2268 uint8_t *tmp_buf = NULL; 2270 uint8_t *tmp_buf = NULL;
2269 2271
2270 /* Open it, check for seekability, set required xd3_source fields. */ 2272 /* Open it, check for seekability, set required xd3_source fields. */
@@ -2296,7 +2298,7 @@ main_set_source (xd3_stream *stream, int cmd, main_file *sfile, xd3_source *sour
2296 if (IS_ENCODE (cmd)) 2298 if (IS_ENCODE (cmd))
2297 { 2299 {
2298 usize_t nread; 2300 usize_t nread;
2299 tmp_buf = main_malloc(XD3_ALLOCSIZE); 2301 tmp_buf = (uint8_t*) main_malloc (XD3_ALLOCSIZE);
2300 2302
2301 if ((ret = main_file_read (sfile, tmp_buf, XD3_ALLOCSIZE, 2303 if ((ret = main_file_read (sfile, tmp_buf, XD3_ALLOCSIZE,
2302 & nread, "source read failed"))) 2304 & nread, "source read failed")))
@@ -2386,7 +2388,7 @@ main_set_source (xd3_stream *stream, int cmd, main_file *sfile, xd3_source *sour
2386 XPR(NT "source block size: %u\n", source->blksize); 2388 XPR(NT "source block size: %u\n", source->blksize);
2387 } 2389 }
2388 2390
2389 if ((lru = main_malloc (sizeof (main_blklru) * lru_size)) == NULL) 2391 if ((lru = (main_blklru*) main_malloc (sizeof (main_blklru) * lru_size)) == NULL)
2390 { 2392 {
2391 ret = ENOMEM; 2393 ret = ENOMEM;
2392 goto error; 2394 goto error;
@@ -2396,7 +2398,7 @@ main_set_source (xd3_stream *stream, int cmd, main_file *sfile, xd3_source *sour
2396 { 2398 {
2397 lru[i].blkno = (xoff_t) -1; 2399 lru[i].blkno = (xoff_t) -1;
2398 2400
2399 if ((lru[i].blk = main_malloc (source->blksize)) == NULL) 2401 if ((lru[i].blk = (uint8_t*) main_malloc (source->blksize)) == NULL)
2400 { 2402 {
2401 ret = ENOMEM; 2403 ret = ENOMEM;
2402 goto error; 2404 goto error;
@@ -2454,13 +2456,13 @@ main_getblk_func (xd3_stream *stream,
2454 xd3_source *source, 2456 xd3_source *source,
2455 xoff_t blkno) 2457 xoff_t blkno)
2456{ 2458{
2457 xoff_t pos = blkno * source->blksize; 2459 int ret;
2458 main_file *sfile = (main_file*) source->ioh; 2460 xoff_t pos = blkno * source->blksize;
2461 main_file *sfile = (main_file*) source->ioh;
2459 main_blklru *blru = NULL; 2462 main_blklru *blru = NULL;
2460 usize_t onblk = xd3_bytes_on_srcblk_fast (source, blkno); 2463 usize_t onblk = xd3_bytes_on_srcblk_fast (source, blkno);
2461 usize_t nread; 2464 usize_t nread;
2462 int ret; 2465 usize_t i;
2463 int i;
2464 2466
2465 if (allow_fake_source) 2467 if (allow_fake_source)
2466 { 2468 {
@@ -2728,7 +2730,7 @@ main_input (xd3_cmd cmd,
2728 2730
2729 main_set_winsize (ifile); 2731 main_set_winsize (ifile);
2730 2732
2731 if ((main_bdata = main_malloc (option_winsize)) == NULL) 2733 if ((main_bdata = (uint8_t*) main_malloc (option_winsize)) == NULL)
2732 { 2734 {
2733 return EXIT_FAILURE; 2735 return EXIT_FAILURE;
2734 } 2736 }
@@ -3048,7 +3050,7 @@ done:
3048static void 3050static void
3049main_cleanup (void) 3051main_cleanup (void)
3050{ 3052{
3051 int i; 3053 usize_t i;
3052 3054
3053 if (appheader_used != NULL && 3055 if (appheader_used != NULL &&
3054 appheader_used != option_appheader) 3056 appheader_used != option_appheader)
@@ -3105,7 +3107,7 @@ setup_environment (int argc,
3105 return; 3107 return;
3106 } 3108 }
3107 3109
3108 (*env_free) = main_malloc(strlen(v) + 1); 3110 (*env_free) = (char*) main_malloc(strlen(v) + 1);
3109 strcpy(*env_free, v); 3111 strcpy(*env_free, v);
3110 3112
3111 /* Space needed for extra args, at least # of spaces */ 3113 /* Space needed for extra args, at least # of spaces */
@@ -3116,7 +3118,7 @@ setup_environment (int argc,
3116 } 3118 }
3117 } 3119 }
3118 3120
3119 (*argv_free) = main_malloc(sizeof(char*) * (n + 1)); 3121 (*argv_free) = (char**) main_malloc(sizeof(char*) * (n + 1));
3120 (*argv_out) = (*argv_free); 3122 (*argv_out) = (*argv_free);
3121 (*argv_out)[0] = argv[0]; 3123 (*argv_out)[0] = argv[0];
3122 (*argv_out)[n] = NULL; 3124 (*argv_out)[n] = NULL;