summaryrefslogtreecommitdiff
path: root/source/fitz
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2016-06-14 17:06:50 +0100
committerRobin Watts <robin.watts@artifex.com>2016-06-17 13:24:47 +0100
commit4a4e6adae4c1a0e9ab3b6fad477edfe26c1a2aca (patch)
tree4ed45be7545229ce5d8bb124a8332b5444004b1b /source/fitz
parentc9bad4ef3e32bc799b134bc3b258f9392cf60e3e (diff)
downloadmupdf-4a4e6adae4c1a0e9ab3b6fad477edfe26c1a2aca.tar.xz
Use 'size_t' instead of int as appropriate.
This silences the many warnings we get when building for x64 in windows. This does not address any of the warnings we get in thirdparty libraries - in particular harfbuzz. These look (at a quick glance) harmless though.
Diffstat (limited to 'source/fitz')
-rw-r--r--source/fitz/bidi-impl.h10
-rw-r--r--source/fitz/bidi-std.c44
-rw-r--r--source/fitz/bidi.c8
-rw-r--r--source/fitz/buffer.c32
-rw-r--r--source/fitz/colorspace.c48
-rw-r--r--source/fitz/crypt-aes.c2
-rw-r--r--source/fitz/crypt-arc4.c8
-rw-r--r--source/fitz/crypt-md5.c6
-rw-r--r--source/fitz/crypt-sha2.c10
-rw-r--r--source/fitz/draw-device.c2
-rw-r--r--source/fitz/draw-glyph.c8
-rw-r--r--source/fitz/draw-unpack.c6
-rw-r--r--source/fitz/filter-basic.c24
-rw-r--r--source/fitz/filter-dct.c4
-rw-r--r--source/fitz/filter-fax.c2
-rw-r--r--source/fitz/filter-flate.c4
-rw-r--r--source/fitz/filter-jbig2.c5
-rw-r--r--source/fitz/filter-leech.c4
-rw-r--r--source/fitz/filter-lzw.c2
-rw-r--r--source/fitz/filter-predict.c16
-rw-r--r--source/fitz/filter-sgi.c6
-rw-r--r--source/fitz/font.c2
-rw-r--r--source/fitz/image.c16
-rw-r--r--source/fitz/load-bmp.c8
-rw-r--r--source/fitz/load-gif.c6
-rw-r--r--source/fitz/load-jpeg.c4
-rw-r--r--source/fitz/load-jpx.c18
-rw-r--r--source/fitz/load-jxr.c4
-rw-r--r--source/fitz/load-png.c6
-rw-r--r--source/fitz/load-tiff.c14
-rw-r--r--source/fitz/memory.c4
-rw-r--r--source/fitz/output.c14
-rw-r--r--source/fitz/printf.c16
-rw-r--r--source/fitz/stext-output.c2
-rw-r--r--source/fitz/store.c4
-rw-r--r--source/fitz/stream-open.c8
-rw-r--r--source/fitz/stream-prog.c10
-rw-r--r--source/fitz/stream-read.c18
-rw-r--r--source/fitz/string.c20
-rw-r--r--source/fitz/svg-device.c2
-rw-r--r--source/fitz/tempfile.c2
-rw-r--r--source/fitz/unzip.c12
-rw-r--r--source/fitz/writer.c2
-rw-r--r--source/fitz/xml.c10
-rw-r--r--source/fitz/zip.c20
45 files changed, 237 insertions, 236 deletions
diff --git a/source/fitz/bidi-impl.h b/source/fitz/bidi-impl.h
index e9a5b3b4..08749879 100644
--- a/source/fitz/bidi-impl.h
+++ b/source/fitz/bidi-impl.h
@@ -72,8 +72,8 @@ enum
BIDI_LEVEL_MAX = 125 /* Updated for 6.3.0 */
};
-void fz_bidi_resolve_neutrals(fz_bidi_level baselevel, fz_bidi_chartype *pcls, const fz_bidi_level *plevel, int cch);
-void fz_bidi_resolve_implicit(const fz_bidi_chartype *pcls, fz_bidi_level *plevel, int cch);
-void fz_bidi_resolve_weak(fz_context *ctx, fz_bidi_level baselevel, fz_bidi_chartype *pcls, fz_bidi_level *plevel, int cch);
-void fz_bidi_resolve_whitespace(fz_bidi_level baselevel, const fz_bidi_chartype *pcls, fz_bidi_level *plevel, int cch);
-int fz_bidi_resolve_explicit(fz_bidi_level level, fz_bidi_chartype dir, fz_bidi_chartype *pcls, fz_bidi_level *plevel, int cch, fz_bidi_level nNest);
+void fz_bidi_resolve_neutrals(fz_bidi_level baselevel, fz_bidi_chartype *pcls, const fz_bidi_level *plevel, size_t cch);
+void fz_bidi_resolve_implicit(const fz_bidi_chartype *pcls, fz_bidi_level *plevel, size_t cch);
+void fz_bidi_resolve_weak(fz_context *ctx, fz_bidi_level baselevel, fz_bidi_chartype *pcls, fz_bidi_level *plevel, size_t cch);
+void fz_bidi_resolve_whitespace(fz_bidi_level baselevel, const fz_bidi_chartype *pcls, fz_bidi_level *plevel, size_t cch);
+size_t fz_bidi_resolve_explicit(fz_bidi_level level, fz_bidi_chartype dir, fz_bidi_chartype *pcls, fz_bidi_level *plevel, size_t cch, fz_bidi_level nNest);
diff --git a/source/fitz/bidi-std.c b/source/fitz/bidi-std.c
index 7315a88d..1f88bdee 100644
--- a/source/fitz/bidi-std.c
+++ b/source/fitz/bidi-std.c
@@ -323,24 +323,24 @@ void reverse(uint32_t *psz, int cch)
// Set a run of cval values at locations all prior to, but not including
// iStart, to the new value nval.
static
-void set_deferred_run(fz_bidi_chartype *pval, int cval, int iStart, fz_bidi_chartype nval)
+void set_deferred_run(fz_bidi_chartype *pval, size_t cval, size_t iStart, fz_bidi_chartype nval)
{
- int i;
+ size_t i;
- for (i = iStart - 1; i >= iStart - cval; i--)
+ for (i = iStart; i > iStart - cval; )
{
- pval[i] = nval;
+ pval[--i] = nval;
}
}
static
-void set_deferred_level_run(fz_bidi_level *pval, int cval, int iStart, fz_bidi_level nval)
+void set_deferred_level_run(fz_bidi_level *pval, size_t cval, size_t iStart, fz_bidi_level nval)
{
- int i;
+ size_t i;
- for (i = iStart - 1; i >= iStart - cval; i--)
+ for (i = iStart; i > iStart - cval; )
{
- pval[i] = nval;
+ pval[--i] = nval;
}
}
@@ -451,10 +451,10 @@ static fz_bidi_chartype embedding_direction(fz_bidi_chartype level)
the outermost call. The nesting counter counts the recursion
depth and not the embedding level.
------------------------------------------------------------------------*/
-int fz_bidi_resolve_explicit(fz_bidi_level level, fz_bidi_chartype dir, fz_bidi_chartype *pcls, fz_bidi_level *plevel, int cch,
+size_t fz_bidi_resolve_explicit(fz_bidi_level level, fz_bidi_chartype dir, fz_bidi_chartype *pcls, fz_bidi_level *plevel, size_t cch,
fz_bidi_level n_nest)
{
- int ich;
+ size_t ich;
// always called with a valid nesting level
// nesting levels are != embedding levels
@@ -704,23 +704,23 @@ fz_bidi_chartype get_resolved_type(fz_bidi_action action)
Note: On input only these directional classes are expected
AL, HL, R, L, ON, BDI_BN, NSM, AN, EN, ES, ET, CS,
------------------------------------------------------------------------*/
-void fz_bidi_resolve_weak(fz_context *ctx, fz_bidi_level baselevel, fz_bidi_chartype *pcls, fz_bidi_level *plevel, int cch)
+void fz_bidi_resolve_weak(fz_context *ctx, fz_bidi_level baselevel, fz_bidi_chartype *pcls, fz_bidi_level *plevel, size_t cch)
{
int state = odd(baselevel) ? xr : xl;
fz_bidi_chartype cls;
- int ich;
+ size_t ich;
fz_bidi_action action;
fz_bidi_chartype cls_run;
fz_bidi_chartype cls_new;
fz_bidi_level level = baselevel;
- int cch_run = 0;
+ size_t cch_run = 0;
for (ich = 0; ich < cch; ich++)
{
if (pcls[ich] > BDI_BN) {
- fz_warn(ctx, "error: pcls[%d] > BN (%d)\n", ich, pcls[ich]);
+ fz_warn(ctx, "error: pcls[" FMT_zu "] > BN (%d)\n", ich, pcls[ich]);
}
// ignore boundary neutrals
@@ -897,15 +897,15 @@ const int state_neutrals[][5] =
W8 resolves a number of ENs to L
------------------------------------------------------------------------*/
-void fz_bidi_resolve_neutrals(fz_bidi_level baselevel, fz_bidi_chartype *pcls, const fz_bidi_level *plevel, int cch)
+void fz_bidi_resolve_neutrals(fz_bidi_level baselevel, fz_bidi_chartype *pcls, const fz_bidi_level *plevel, size_t cch)
{
// the state at the start of text depends on the base level
int state = odd(baselevel) ? r : l;
fz_bidi_chartype cls;
- int ich;
+ size_t ich;
fz_bidi_chartype cls_run;
- int cch_run = 0;
+ size_t cch_run = 0;
fz_bidi_level level = baselevel;
for (ich = 0; ich < cch; ich++)
@@ -985,9 +985,9 @@ const fz_bidi_level add_level[][4] =
};
-void fz_bidi_resolve_implicit(const fz_bidi_chartype *pcls, fz_bidi_level *plevel, int cch)
+void fz_bidi_resolve_implicit(const fz_bidi_chartype *pcls, fz_bidi_level *plevel, size_t cch)
{
- int ich;
+ size_t ich;
for (ich = 0; ich < cch; ich++)
{
@@ -1058,11 +1058,11 @@ static int resolve_lines(uint32_t *psz_input, int *pbrk, int cch)
would have to be adjusted.
------------------------------------------------------------------------*/
void fz_bidi_resolve_whitespace(fz_bidi_level baselevel, const fz_bidi_chartype *pcls, fz_bidi_level *plevel,
- int cch)
+ size_t cch)
{
- int cchrun = 0;
+ size_t cchrun = 0;
fz_bidi_level oldlevel = baselevel;
- int ich;
+ size_t ich;
for (ich = 0; ich < cch; ich++)
{
diff --git a/source/fitz/bidi.c b/source/fitz/bidi.c
index 7d3ca3a2..e05347b7 100644
--- a/source/fitz/bidi.c
+++ b/source/fitz/bidi.c
@@ -219,10 +219,10 @@ split_at_script(const uint32_t *fragment,
static void
classify_characters(const uint32_t *text,
fz_bidi_chartype *types,
- int len,
+ size_t len,
fz_bidi_flags flags)
{
- int i;
+ size_t i;
if ((flags & BIDI_CLASSIFY_WHITE_SPACE)!=0)
{
@@ -264,9 +264,9 @@ classify_characters(const uint32_t *text,
* Implements rule P2 of the Unicode Bidi Algorithm.
* Note: Ignores explicit embeddings
*/
-static fz_bidi_level base_level_from_text(fz_bidi_chartype *types, int len)
+static fz_bidi_level base_level_from_text(fz_bidi_chartype *types, size_t len)
{
- int i;
+ size_t i;
for (i = 0; i < len; i++)
{
diff --git a/source/fitz/buffer.c b/source/fitz/buffer.c
index 4cff8715..190088e3 100644
--- a/source/fitz/buffer.c
+++ b/source/fitz/buffer.c
@@ -1,7 +1,7 @@
#include "mupdf/fitz.h"
fz_buffer *
-fz_new_buffer(fz_context *ctx, int size)
+fz_new_buffer(fz_context *ctx, size_t size)
{
fz_buffer *b;
@@ -26,7 +26,7 @@ fz_new_buffer(fz_context *ctx, int size)
}
fz_buffer *
-fz_new_buffer_from_data(fz_context *ctx, unsigned char *data, int size)
+fz_new_buffer_from_data(fz_context *ctx, unsigned char *data, size_t size)
{
fz_buffer *b;
@@ -41,7 +41,7 @@ fz_new_buffer_from_data(fz_context *ctx, unsigned char *data, int size)
}
fz_buffer *
-fz_new_buffer_from_shared_data(fz_context *ctx, const char *data, int size)
+fz_new_buffer_from_shared_data(fz_context *ctx, const char *data, size_t size)
{
fz_buffer *b;
@@ -57,7 +57,7 @@ fz_new_buffer_from_shared_data(fz_context *ctx, const char *data, int size)
}
fz_buffer *
-fz_new_buffer_from_base64(fz_context *ctx, const char *data, int size)
+fz_new_buffer_from_base64(fz_context *ctx, const char *data, size_t size)
{
fz_buffer *buf = fz_new_buffer(ctx, size);
const char *end = data + size;
@@ -109,7 +109,7 @@ fz_drop_buffer(fz_context *ctx, fz_buffer *buf)
}
void
-fz_resize_buffer(fz_context *ctx, fz_buffer *buf, int size)
+fz_resize_buffer(fz_context *ctx, fz_buffer *buf, size_t size)
{
if (buf->shared)
fz_throw(ctx, FZ_ERROR_GENERIC, "cannot resize a buffer with shared storage");
@@ -122,16 +122,16 @@ fz_resize_buffer(fz_context *ctx, fz_buffer *buf, int size)
void
fz_grow_buffer(fz_context *ctx, fz_buffer *buf)
{
- int newsize = (buf->cap * 3) / 2;
+ size_t newsize = (buf->cap * 3) / 2;
if (newsize == 0)
newsize = 256;
fz_resize_buffer(ctx, buf, newsize);
}
static void
-fz_ensure_buffer(fz_context *ctx, fz_buffer *buf, int min)
+fz_ensure_buffer(fz_context *ctx, fz_buffer *buf, size_t min)
{
- int newsize = buf->cap;
+ size_t newsize = buf->cap;
if (newsize < 16)
newsize = 16;
while (newsize < min)
@@ -148,7 +148,7 @@ fz_trim_buffer(fz_context *ctx, fz_buffer *buf)
fz_resize_buffer(ctx, buf, buf->len);
}
-int
+size_t
fz_buffer_storage(fz_context *ctx, fz_buffer *buf, unsigned char **datap)
{
if (datap)
@@ -169,7 +169,7 @@ fz_append_buffer(fz_context *ctx, fz_buffer *buf, fz_buffer *extra)
buf->len += extra->len;
}
-void fz_write_buffer(fz_context *ctx, fz_buffer *buf, const void *data, int len)
+void fz_write_buffer(fz_context *ctx, fz_buffer *buf, const void *data, size_t len)
{
if (buf->len + len > buf->cap)
fz_ensure_buffer(ctx, buf, buf->len + len);
@@ -277,10 +277,10 @@ void fz_write_buffer_pad(fz_context *ctx, fz_buffer *buf)
buf->unused_bits = 0;
}
-int
+size_t
fz_buffer_printf(fz_context *ctx, fz_buffer *buffer, const char *fmt, ...)
{
- int ret;
+ size_t ret;
va_list args;
va_start(args, fmt);
ret = fz_buffer_vprintf(ctx, buffer, fmt, args);
@@ -288,11 +288,11 @@ fz_buffer_printf(fz_context *ctx, fz_buffer *buffer, const char *fmt, ...)
return ret;
}
-int
+size_t
fz_buffer_vprintf(fz_context *ctx, fz_buffer *buffer, const char *fmt, va_list old_args)
{
- int slack;
- int len;
+ size_t slack;
+ size_t len;
va_list args;
slack = buffer->cap - buffer->len;
@@ -321,7 +321,7 @@ fz_buffer_vprintf(fz_context *ctx, fz_buffer *buffer, const char *fmt, va_list o
void
fz_buffer_print_pdf_string(fz_context *ctx, fz_buffer *buffer, const char *text)
{
- int len = 2;
+ size_t len = 2;
const char *s = text;
char *d;
char c;
diff --git a/source/fitz/colorspace.c b/source/fitz/colorspace.c
index 89f16e30..d30f98eb 100644
--- a/source/fitz/colorspace.c
+++ b/source/fitz/colorspace.c
@@ -291,8 +291,8 @@ static void fast_gray_to_rgb(fz_pixmap *dst, fz_pixmap *src)
unsigned char *d = dst->samples;
size_t w = src->w;
int h = src->h;
- int d_line_inc = dst->stride - w * (dst->alpha + 3);
- int s_line_inc = src->stride - w * (src->alpha + 1);
+ ptrdiff_t d_line_inc = dst->stride - w * (dst->alpha + 3);
+ ptrdiff_t s_line_inc = src->stride - w * (src->alpha + 1);
if ((int)w < 0 || h < 0)
return;
@@ -369,8 +369,8 @@ static void fast_gray_to_cmyk(fz_pixmap *dst, fz_pixmap *src)
unsigned char *d = dst->samples;
size_t w = src->w;
int h = src->h;
- int d_line_inc = dst->stride - w * (dst->alpha + 4);
- int s_line_inc = src->stride - w * (src->alpha + 1);
+ ptrdiff_t d_line_inc = dst->stride - w * (dst->alpha + 4);
+ ptrdiff_t s_line_inc = src->stride - w * (src->alpha + 1);
if ((int)w < 0 || h < 0)
return;
@@ -450,8 +450,8 @@ static void fast_rgb_to_gray(fz_pixmap *dst, fz_pixmap *src)
unsigned char *d = dst->samples;
size_t w = src->w;
int h = src->h;
- int d_line_inc = dst->stride - w * (dst->alpha + 1);
- int s_line_inc = src->stride - w * (src->alpha + 3);
+ ptrdiff_t d_line_inc = dst->stride - w * (dst->alpha + 1);
+ ptrdiff_t s_line_inc = src->stride - w * (src->alpha + 3);
if ((int)w < 0 || h < 0)
return;
@@ -522,8 +522,8 @@ static void fast_bgr_to_gray(fz_pixmap *dst, fz_pixmap *src)
unsigned char *d = dst->samples;
size_t w = src->w;
int h = src->h;
- int d_line_inc = dst->stride - w * (dst->alpha + 1);
- int s_line_inc = src->stride - w * (src->alpha + 3);
+ ptrdiff_t d_line_inc = dst->stride - w * (dst->alpha + 1);
+ ptrdiff_t s_line_inc = src->stride - w * (src->alpha + 3);
if ((int)w < 0 || h < 0)
return;
@@ -594,8 +594,8 @@ static void fast_rgb_to_cmyk(fz_pixmap *dst, fz_pixmap *src)
unsigned char *d = dst->samples;
size_t w = src->w;
int h = src->h;
- int d_line_inc = dst->stride - w * (dst->alpha + 4);
- int s_line_inc = src->stride - w * (src->alpha + 3);
+ ptrdiff_t d_line_inc = dst->stride - w * (dst->alpha + 4);
+ ptrdiff_t s_line_inc = src->stride - w * (src->alpha + 3);
if ((int)w < 0 || h < 0)
return;
@@ -687,8 +687,8 @@ static void fast_bgr_to_cmyk(fz_pixmap *dst, fz_pixmap *src)
unsigned char *d = dst->samples;
size_t w = src->w;
int h = src->h;
- int d_line_inc = dst->stride - w * (dst->alpha + 4);
- int s_line_inc = src->stride - w * (src->alpha + 3);
+ ptrdiff_t d_line_inc = dst->stride - w * (dst->alpha + 4);
+ ptrdiff_t s_line_inc = src->stride - w * (src->alpha + 3);
if ((int)w < 0 || h < 0)
return;
@@ -780,8 +780,8 @@ static void fast_cmyk_to_gray(fz_pixmap *dst, fz_pixmap *src)
unsigned char *d = dst->samples;
size_t w = src->w;
int h = src->h;
- int d_line_inc = dst->stride - w * (dst->alpha + 1);
- int s_line_inc = src->stride - w * (src->alpha + 4);
+ ptrdiff_t d_line_inc = dst->stride - w * (dst->alpha + 1);
+ ptrdiff_t s_line_inc = src->stride - w * (src->alpha + 4);
if ((int)w < 0 || h < 0)
return;
@@ -1187,8 +1187,8 @@ static void fast_cmyk_to_rgb(fz_context *ctx, fz_pixmap *dst, fz_pixmap *src)
unsigned char *d = dst->samples;
size_t w = src->w;
int h = src->h;
- int d_line_inc = dst->stride - w * (dst->alpha + 3);
- int s_line_inc = src->stride - w * (src->alpha + 4);
+ ptrdiff_t d_line_inc = dst->stride - w * (dst->alpha + 3);
+ ptrdiff_t s_line_inc = src->stride - w * (src->alpha + 4);
unsigned int C,M,Y,K;
unsigned char r,g,b;
@@ -1286,8 +1286,8 @@ static void fast_cmyk_to_bgr(fz_context *ctx, fz_pixmap *dst, fz_pixmap *src)
unsigned char *d = dst->samples;
size_t w = src->w;
int h = src->h;
- int d_line_inc = dst->stride - w * (dst->alpha + 3);
- int s_line_inc = src->stride - w * (src->alpha + 4);
+ ptrdiff_t d_line_inc = dst->stride - w * (dst->alpha + 3);
+ ptrdiff_t s_line_inc = src->stride - w * (src->alpha + 4);
unsigned int C,M,Y,K;
unsigned char r,g,b;
@@ -1378,8 +1378,8 @@ static void fast_rgb_to_bgr(fz_pixmap *dst, fz_pixmap *src)
unsigned char *d = dst->samples;
size_t w = src->w;
int h = src->h;
- int d_line_inc = dst->stride - w * (dst->alpha + 3);
- int s_line_inc = src->stride - w * (src->alpha + 3);
+ ptrdiff_t d_line_inc = dst->stride - w * (dst->alpha + 3);
+ ptrdiff_t s_line_inc = src->stride - w * (src->alpha + 3);
if ((int)w < 0 || h < 0)
return;
@@ -1454,8 +1454,8 @@ fz_std_conv_pixmap(fz_context *ctx, fz_pixmap *dst, fz_pixmap *src)
int k, i;
size_t w = src->w;
int h = src->h;
- int d_line_inc = dst->stride - w * dst->n;
- int s_line_inc = src->stride - w * src->n;
+ ptrdiff_t d_line_inc = dst->stride - w * dst->n;
+ ptrdiff_t s_line_inc = src->stride - w * src->n;
int da = dst->alpha;
int sa = src->alpha;
@@ -1641,8 +1641,8 @@ static void fast_copy_alpha(fz_pixmap *dst, fz_pixmap *src)
size_t w = src->w;
int h = src->h;
int n = src->n;
- int d_line_inc = dst->stride - w * dst->n;
- int s_line_inc = src->stride - w * src->n;
+ ptrdiff_t d_line_inc = dst->stride - w * dst->n;
+ ptrdiff_t s_line_inc = src->stride - w * src->n;
if ((int)w < 0 || h < 0)
return;
diff --git a/source/fitz/crypt-aes.c b/source/fitz/crypt-aes.c
index f98fb8fd..cc298731 100644
--- a/source/fitz/crypt-aes.c
+++ b/source/fitz/crypt-aes.c
@@ -475,7 +475,7 @@ void aes_crypt_ecb( aes_context *ctx,
*/
void aes_crypt_cbc( aes_context *ctx,
int mode,
- int length,
+ size_t length,
unsigned char iv[16],
const unsigned char *input,
unsigned char *output )
diff --git a/source/fitz/crypt-arc4.c b/source/fitz/crypt-arc4.c
index 9c54fbae..6031f1ff 100644
--- a/source/fitz/crypt-arc4.c
+++ b/source/fitz/crypt-arc4.c
@@ -24,10 +24,10 @@
#include "mupdf/fitz.h"
void
-fz_arc4_init(fz_arc4 *arc4, const unsigned char *key, unsigned keylen)
+fz_arc4_init(fz_arc4 *arc4, const unsigned char *key, size_t keylen)
{
unsigned int t, u;
- unsigned int keyindex;
+ size_t keyindex;
unsigned int stateindex;
unsigned char *state;
unsigned int counter;
@@ -86,9 +86,9 @@ fz_arc4_next(fz_arc4 *arc4)
}
void
-fz_arc4_encrypt(fz_arc4 *arc4, unsigned char *dest, const unsigned char *src, unsigned len)
+fz_arc4_encrypt(fz_arc4 *arc4, unsigned char *dest, const unsigned char *src, size_t len)
{
- unsigned int i;
+ size_t i;
for (i = 0; i < len; i++)
{
unsigned char x;
diff --git a/source/fitz/crypt-md5.c b/source/fitz/crypt-md5.c
index 7490c0bc..d2693b05 100644
--- a/source/fitz/crypt-md5.c
+++ b/source/fitz/crypt-md5.c
@@ -210,12 +210,12 @@ void fz_md5_init(fz_md5 *context)
/* MD5 block update operation. Continues an MD5 message-digest operation,
* processing another message block, and updating the context.
*/
-void fz_md5_update(fz_md5 *context, const unsigned char *input, unsigned inlen)
+void fz_md5_update(fz_md5 *context, const unsigned char *input, size_t inlen)
{
- unsigned i, index, partlen;
+ size_t i, index, partlen;
/* Compute number of bytes mod 64 */
- index = (unsigned)((context->count[0] >> 3) & 0x3F);
+ index = (size_t)((context->count[0] >> 3) & 0x3F);
/* Update number of bits */
context->count[0] += (unsigned int) inlen << 3;
diff --git a/source/fitz/crypt-sha2.c b/source/fitz/crypt-sha2.c
index 329069fb..20f827fe 100644
--- a/source/fitz/crypt-sha2.c
+++ b/source/fitz/crypt-sha2.c
@@ -142,7 +142,7 @@ void fz_sha256_init(fz_sha256 *context)
context->state[7] = 0x5BE0CD19;
}
-void fz_sha256_update(fz_sha256 *context, const unsigned char *input, unsigned int inlen)
+void fz_sha256_update(fz_sha256 *context, const unsigned char *input, size_t inlen)
{
/* Copy the input data into a properly aligned temporary buffer.
* This way we can be called with arbitrarily sized buffers
@@ -153,7 +153,7 @@ void fz_sha256_update(fz_sha256 *context, const unsigned char *input, unsigned i
const unsigned int copy_start = context->count[0] & 0x3F;
unsigned int copy_size = 64 - copy_start;
if (copy_size > inlen)
- copy_size = inlen;
+ copy_size = (unsigned int)inlen;
memcpy(context->buffer.u8 + copy_start, input, copy_size);
@@ -314,7 +314,7 @@ void fz_sha512_init(fz_sha512 *context)
context->state[7] = 0x5BE0CD19137E2179ull;
}
-void fz_sha512_update(fz_sha512 *context, const unsigned char *input, unsigned int inlen)
+void fz_sha512_update(fz_sha512 *context, const unsigned char *input, size_t inlen)
{
/* Copy the input data into a properly aligned temporary buffer.
* This way we can be called with arbitrarily sized buffers
@@ -325,7 +325,7 @@ void fz_sha512_update(fz_sha512 *context, const unsigned char *input, unsigned i
const unsigned int copy_start = context->count[0] & 0x7F;
unsigned int copy_size = 128 - copy_start;
if (copy_size > inlen)
- copy_size = inlen;
+ copy_size = (unsigned int)inlen;
memcpy(context->buffer.u8 + copy_start, input, copy_size);
@@ -396,7 +396,7 @@ void fz_sha384_init(fz_sha384 *context)
context->state[7] = 0x47B5481DBEFA4FA4ull;
}
-void fz_sha384_update(fz_sha384 *context, const unsigned char *input, unsigned int inlen)
+void fz_sha384_update(fz_sha384 *context, const unsigned char *input, size_t inlen)
{
fz_sha512_update(context, input, inlen);
}
diff --git a/source/fitz/draw-device.c b/source/fitz/draw-device.c
index 126f715d..bdfa1085 100644
--- a/source/fitz/draw-device.c
+++ b/source/fitz/draw-device.c
@@ -13,7 +13,7 @@ const char *fz_draw_options_usage =
static int opteq(const char *a, const char *b)
{
- int n = strlen(b);
+ size_t n = strlen(b);
return !strncmp(a, b, n) && (a[n] == ',' || a[n] == 0);
}
diff --git a/source/fitz/draw-glyph.c b/source/fitz/draw-glyph.c
index 98f9252b..014cc13a 100644
--- a/source/fitz/draw-glyph.c
+++ b/source/fitz/draw-glyph.c
@@ -33,10 +33,10 @@ struct fz_glyph_cache_entry_s
struct fz_glyph_cache_s
{
int refs;
- int total;
+ size_t total;
#ifndef NDEBUG
int num_evictions;
- int evicted;
+ ptrdiff_t evicted;
#endif
fz_glyph_cache_entry *entry[GLYPH_HASH_LEN];
fz_glyph_cache_entry *lru_head;
@@ -453,8 +453,8 @@ fz_dump_glyph_cache_stats(fz_context *ctx)
{
fz_glyph_cache *cache = ctx->glyph_cache;
- fprintf(stderr, "Glyph Cache Size: %d\n", cache->total);
+ fprintf(stderr, "Glyph Cache Size: " FMT_zu "\n", cache->total);
#ifndef NDEBUG
- fprintf(stderr, "Glyph Cache Evictions: %d (%d bytes)\n", cache->num_evictions, cache->evicted);
+ fprintf(stderr, "Glyph Cache Evictions: %d (" FMT_zu " bytes)\n", cache->num_evictions, cache->evicted);
#endif
}
diff --git a/source/fitz/draw-unpack.c b/source/fitz/draw-unpack.c
index 0211b7e4..d2a0c72e 100644
--- a/source/fitz/draw-unpack.c
+++ b/source/fitz/draw-unpack.c
@@ -47,7 +47,7 @@ init_get1_tables(void)
}
void
-fz_unpack_tile(fz_context *ctx, fz_pixmap *dst, unsigned char * restrict src, int n, int depth, int stride, int scale)
+fz_unpack_tile(fz_context *ctx, fz_pixmap *dst, unsigned char * restrict src, int n, int depth, size_t stride, int scale)
{
int pad, x, y, k;
int w = dst->w;
@@ -71,8 +71,8 @@ fz_unpack_tile(fz_context *ctx, fz_pixmap *dst, unsigned char * restrict src, in
for (y = 0; y < dst->h; y++)
{
- unsigned char *sp = src + (unsigned int)(y * stride);
- unsigned char *dp = dst->samples + (unsigned int)(y * dst->stride);
+ unsigned char *sp = src + (y * stride);
+ unsigned char *dp = dst->samples + (y * dst->stride);
/* Specialized loops */
diff --git a/source/fitz/filter-basic.c b/source/fitz/filter-basic.c
index 20bb6619..0211442c 100644
--- a/source/fitz/filter-basic.c
+++ b/source/fitz/filter-basic.c
@@ -13,16 +13,16 @@ fz_open_copy(fz_context *ctx, fz_stream *chain)
struct null_filter
{
fz_stream *chain;
- int remain;
+ size_t remain;
fz_off_t offset;
unsigned char buffer[4096];
};
static int
-next_null(fz_context *ctx, fz_stream *stm, int max)
+next_null(fz_context *ctx, fz_stream *stm, size_t max)
{
struct null_filter *state = stm->state;
- int n;
+ size_t n;
if (state->remain == 0)
return EOF;
@@ -89,10 +89,10 @@ struct concat_filter
};
static int
-next_concat(fz_context *ctx, fz_stream *stm, int max)
+next_concat(fz_context *ctx, fz_stream *stm, size_t max)
{
struct concat_filter *state = (struct concat_filter *)stm->state;
- int n;
+ size_t n;
while (state->current < state->count)
{
@@ -207,7 +207,7 @@ static inline int unhex(int a)
}
static int
-next_ahxd(fz_context *ctx, fz_stream *stm, int max)
+next_ahxd(fz_context *ctx, fz_stream *stm, size_t max)
{
fz_ahxd *state = stm->state;
unsigned char *p = state->buffer;
@@ -305,7 +305,7 @@ struct fz_a85d_s
};
static int
-next_a85d(fz_context *ctx, fz_stream *stm, int max)
+next_a85d(fz_context *ctx, fz_stream *stm, size_t max)
{
fz_a85d *state = stm->state;
unsigned char *p = state->buffer;
@@ -449,7 +449,7 @@ struct fz_rld_s
};
static int
-next_rld(fz_context *ctx, fz_stream *stm, int max)
+next_rld(fz_context *ctx, fz_stream *stm, size_t max)
{
fz_rld *state = stm->state;
unsigned char *p = state->buffer;
@@ -562,10 +562,10 @@ struct fz_arc4c_s
};
static int
-next_arc4(fz_context *ctx, fz_stream *stm, int max)
+next_arc4(fz_context *ctx, fz_stream *stm, size_t max)
{
fz_arc4c *state = stm->state;
- int n = fz_available(ctx, state->chain, max);
+ size_t n = fz_available(ctx, state->chain, max);
if (n == 0)
return EOF;
@@ -627,7 +627,7 @@ struct fz_aesd_s
};
static int
-next_aesd(fz_context *ctx, fz_stream *stm, int max)
+next_aesd(fz_context *ctx, fz_stream *stm, size_t max)
{
fz_aesd *state = stm->state;
unsigned char *p = state->buffer;
@@ -650,7 +650,7 @@ next_aesd(fz_context *ctx, fz_stream *stm, int max)
while (p < ep)
{
- int n = fz_read(ctx, state->chain, state->bp, 16);
+ size_t n = fz_read(ctx, state->chain, state->bp, 16);
if (n == 0)
break;
else if (n < 16)
diff --git a/source/fitz/filter-dct.c b/source/fitz/filter-dct.c
index c18ae79d..fee39f69 100644
--- a/source/fitz/filter-dct.c
+++ b/source/fitz/filter-dct.c
@@ -140,7 +140,7 @@ static void skip_input_data(j_decompress_ptr cinfo, long num_bytes)
{
while ((size_t)num_bytes > src->bytes_in_buffer)
{
- num_bytes -= src->bytes_in_buffer;
+ num_bytes -= (long)src->bytes_in_buffer;
(void) src->fill_input_buffer(cinfo);
}
src->next_input_byte += num_bytes;
@@ -149,7 +149,7 @@ static void skip_input_data(j_decompress_ptr cinfo, long num_bytes)
}
static int
-next_dctd(fz_context *ctx, fz_stream *stm, int max)
+next_dctd(fz_context *ctx, fz_stream *stm, size_t max)
{
fz_dctd *state = stm->state;
j_decompress_ptr cinfo = &state->cinfo;
diff --git a/source/fitz/filter-fax.c b/source/fitz/filter-fax.c
index 7a4d7485..74297936 100644
--- a/source/fitz/filter-fax.c
+++ b/source/fitz/filter-fax.c
@@ -539,7 +539,7 @@ dec2d(fz_context *ctx, fz_faxd *fax)
}
static int
-next_faxd(fz_context *ctx, fz_stream *stm, int max)
+next_faxd(fz_context *ctx, fz_stream *stm, size_t max)
{
fz_faxd *fax = stm->state;
unsigned char *p = fax->buffer;
diff --git a/source/fitz/filter-flate.c b/source/fitz/filter-flate.c
index 46ff6970..31519066 100644
--- a/source/fitz/filter-flate.c
+++ b/source/fitz/filter-flate.c
@@ -22,7 +22,7 @@ static void zfree(void *opaque, void *ptr)
}
static int
-next_flated(fz_context *ctx, fz_stream *stm, int required)
+next_flated(fz_context *ctx, fz_stream *stm, size_t required)
{
fz_flate *state = stm->state;
fz_stream *chain = state->chain;
@@ -39,7 +39,7 @@ next_flated(fz_context *ctx, fz_stream *stm, int required)
while (zp->avail_out > 0)
{
- zp->avail_in = fz_available(ctx, chain, 1);
+ zp->avail_in = (uInt)fz_available(ctx, chain, 1);
zp->next_in = chain->rp;
code = inflate(zp, Z_SYNC_FLUSH);
diff --git a/source/fitz/filter-jbig2.c b/source/fitz/filter-jbig2.c
index b90f1d42..0ce72201 100644
--- a/source/fitz/filter-jbig2.c
+++ b/source/fitz/filter-jbig2.c
@@ -287,7 +287,7 @@ close_jbig2d(fz_context *ctx, void *state_)
}
static int
-next_jbig2d(fz_context *ctx, fz_stream *stm, int len)
+next_jbig2d(fz_context *ctx, fz_stream *stm, size_t len)
{
fz_jbig2d *state = stm->state;
unsigned char tmp[4096];
@@ -295,7 +295,8 @@ next_jbig2d(fz_context *ctx, fz_stream *stm, int len)
unsigned char *p = buf;
unsigned char *ep;
unsigned char *s;
- int x, w, n;
+ int x, w;
+ size_t n;
if (len > sizeof(state->buffer))
len = sizeof(state->buffer);
diff --git a/source/fitz/filter-leech.c b/source/fitz/filter-leech.c
index 90e28565..c8f28b7c 100644
--- a/source/fitz/filter-leech.c
+++ b/source/fitz/filter-leech.c
@@ -11,11 +11,11 @@ struct fz_leech_s
};
static int
-next_leech(fz_context *ctx, fz_stream *stm, int max)
+next_leech(fz_context *ctx, fz_stream *stm, size_t max)
{
fz_leech *state = stm->state;
fz_buffer *buffer = state->buffer;
- int n = fz_available(ctx, state->chain, max);
+ size_t n = fz_available(ctx, state->chain, max);
if (n > max)
n = max;
diff --git a/source/fitz/filter-lzw.c b/source/fitz/filter-lzw.c
index cb977772..d7b97407 100644
--- a/source/fitz/filter-lzw.c
+++ b/source/fitz/filter-lzw.c
@@ -49,7 +49,7 @@ struct fz_lzwd_s
};
static int
-next_lzwd(fz_context *ctx, fz_stream *stm, int len)
+next_lzwd(fz_context *ctx, fz_stream *stm, size_t len)
{
fz_lzwd *lzw = stm->state;
lzw_code *table = lzw->table;
diff --git a/source/fitz/filter-predict.c b/source/fitz/filter-predict.c
index 3136c651..02475c41 100644
--- a/source/fitz/filter-predict.c
+++ b/source/fitz/filter-predict.c
@@ -59,7 +59,7 @@ static inline int paeth(int a, int b, int c)
}
static void
-fz_predict_tiff(fz_predict *state, unsigned char *out, unsigned char *in, int len)
+fz_predict_tiff(fz_predict *state, unsigned char *out, unsigned char *in)
{
int left[FZ_MAX_COLORS];
int i, k;
@@ -95,14 +95,14 @@ fz_predict_tiff(fz_predict *state, unsigned char *out, unsigned char *in, int le
}
static void
-fz_predict_png(fz_predict *state, unsigned char *out, unsigned char *in, int len, int predictor)
+fz_predict_png(fz_predict *state, unsigned char *out, unsigned char *in, size_t len, int predictor)
{
int bpp = state->bpp;
- int i;
+ size_t i;
unsigned char *ref = state->ref;
- if (bpp > len)
- bpp = len;
+ if ((size_t)bpp > len)
+ bpp = (int)len;
switch (predictor)
{
@@ -157,14 +157,14 @@ fz_predict_png(fz_predict *state, unsigned char *out, unsigned char *in, int len
}
static int
-next_predict(fz_context *ctx, fz_stream *stm, int len)
+next_predict(fz_context *ctx, fz_stream *stm, size_t len)
{
fz_predict *state = stm->state;
unsigned char *buf = state->buffer;
unsigned char *p = buf;
unsigned char *ep;
int ispng = state->predictor >= 10;
- int n;
+ size_t n;
if (len >= sizeof(state->buffer))
len = sizeof(state->buffer);
@@ -182,7 +182,7 @@ next_predict(fz_context *ctx, fz_stream *stm, int len)
if (state->predictor == 1)
memcpy(state->out, state->in, n);
else if (state->predictor == 2)
- fz_predict_tiff(state, state->out, state->in, n);
+ fz_predict_tiff(state, state->out, state->in);
else
{
fz_predict_png(state, state->out, state->in + 1, n - 1, state->in[0]);
diff --git a/source/fitz/filter-sgi.c b/source/fitz/filter-sgi.c
index c0fd9a74..ceb2a548 100644
--- a/source/fitz/filter-sgi.c
+++ b/source/fitz/filter-sgi.c
@@ -214,7 +214,7 @@ sgilog16val(fz_context *ctx, uint16_t v)
}
static int
-next_sgilog16(fz_context *ctx, fz_stream *stm, int max)
+next_sgilog16(fz_context *ctx, fz_stream *stm, size_t max)
{
fz_sgilog16 *state = stm->state;
uint16_t *p;
@@ -434,7 +434,7 @@ sgilog24val(fz_context *ctx, fz_stream *chain, uint8_t *rgb)
}
static int
-next_sgilog24(fz_context *ctx, fz_stream *stm, int max)
+next_sgilog24(fz_context *ctx, fz_stream *stm, size_t max)
{
fz_sgilog24 *state = stm->state;
uint8_t *p;
@@ -557,7 +557,7 @@ sgilog32val(fz_context *ctx, uint32_t p, uint8_t *rgb)
}
static int
-next_sgilog32(fz_context *ctx, fz_stream *stm, int max)
+next_sgilog32(fz_context *ctx, fz_stream *stm, size_t max)
{
fz_sgilog32 *state = stm->state;
uint32_t *p;
diff --git a/source/fitz/font.c b/source/fitz/font.c
index 6cc80d0e..cebccf03 100644
--- a/source/fitz/font.c
+++ b/source/fitz/font.c
@@ -437,7 +437,7 @@ fz_new_font_from_buffer(fz_context *ctx, const char *name, fz_buffer *buffer, in
fz_keep_freetype(ctx);
fz_lock(ctx, FZ_LOCK_FREETYPE);
- fterr = FT_New_Memory_Face(ctx->font->ftlib, buffer->data, buffer->len, index, &face);
+ fterr = FT_New_Memory_Face(ctx->font->ftlib, buffer->data, (FT_Long)buffer->len, index, &face);
fz_unlock(ctx, FZ_LOCK_FREETYPE);
if (fterr)
{
diff --git a/source/fitz/image.c b/source/fitz/image.c
index 59d09bf1..6f840c38 100644
--- a/source/fitz/image.c
+++ b/source/fitz/image.c
@@ -169,7 +169,7 @@ fz_decomp_image_from_stream(fz_context *ctx, fz_stream *stm, fz_compressed_image
{
fz_image *image = &cimg->super;
fz_pixmap *tile = NULL;
- int stride, len, i;
+ size_t stride, len, i;
unsigned char *samples = NULL;
int f = 1<<l2factor;
int w = image->w;
@@ -251,16 +251,16 @@ fz_decomp_image_from_stream(fz_context *ctx, fz_stream *stm, fz_compressed_image
int hh;
unsigned char *s = samples;
int stream_w = (image->w + f - 1)>>l2factor;
- int stream_stride = (stream_w * image->n * image->bpc + 7) / 8;
+ size_t stream_stride = (stream_w * image->n * image->bpc + 7) / 8;
int l_margin = subarea->x0 >> l2factor;
int t_margin = subarea->y0 >> l2factor;
int r_margin = (image->w + f - 1 - subarea->x1) >> l2factor;
int b_margin = (image->h + f - 1 - subarea->y1) >> l2factor;
int l_skip = (l_margin * image->n * image->bpc)/8;
int r_skip = (r_margin * image->n * image->bpc + 7)/8;
- int t_skip = t_margin * stream_stride + l_skip;
- int b_skip = b_margin * stream_stride + r_skip;
- int l = fz_skip(ctx, stm, t_skip);
+ size_t t_skip = t_margin * stream_stride + l_skip;
+ size_t b_skip = b_margin * stream_stride + r_skip;
+ size_t l = fz_skip(ctx, stm, t_skip);
len = 0;
if (l == t_skip)
{
@@ -275,7 +275,7 @@ fz_decomp_image_from_stream(fz_context *ctx, fz_stream *stm, fz_compressed_image
if (--hh == 0)
break;
l = fz_skip(ctx, stm, r_skip + l_skip);
- if (l < r_skip + l_skip)
+ if (l < (size_t)(r_skip + l_skip))
break;
}
while (1);
@@ -864,7 +864,7 @@ void fz_set_pixmap_image_tile(fz_context *ctx, fz_pixmap_image *image, fz_pixmap
}
fz_image *
-fz_new_image_from_data(fz_context *ctx, unsigned char *data, int len)
+fz_new_image_from_data(fz_context *ctx, unsigned char *data, size_t len)
{
fz_buffer *buffer = NULL;
fz_image *image;
@@ -897,7 +897,7 @@ fz_new_image_from_buffer(fz_context *ctx, fz_buffer *buffer)
fz_compressed_buffer *bc = NULL;
int w, h, xres, yres;
fz_colorspace *cspace = NULL;
- int len = buffer->len;
+ size_t len = buffer->len;
unsigned char *buf = buffer->data;
fz_image *image;
diff --git a/source/fitz/load-bmp.c b/source/fitz/load-bmp.c
index 5f23e4fe..5e630b5a 100644
--- a/source/fitz/load-bmp.c
+++ b/source/fitz/load-bmp.c
@@ -847,7 +847,7 @@ bmp_read_bitmap(fz_context *ctx, struct info *info, unsigned char *p, unsigned c
}
static fz_pixmap *
-bmp_read_image(fz_context *ctx, struct info *info, unsigned char *p, int total, int only_metadata)
+bmp_read_image(fz_context *ctx, struct info *info, unsigned char *p, size_t total, int only_metadata)
{
unsigned char *begin = p;
unsigned char *end = p + total;
@@ -857,7 +857,7 @@ bmp_read_image(fz_context *ctx, struct info *info, unsigned char *p, int total,
p = bmp_read_file_header(ctx, info, p, end);
- info->filesize = fz_mini(info->filesize, total);
+ info->filesize = fz_mini(info->filesize, (int)total);
if (end - p < 4)
fz_throw(ctx, FZ_ERROR_GENERIC, "premature end in bitmap core header in bmp image");
@@ -936,7 +936,7 @@ bmp_read_image(fz_context *ctx, struct info *info, unsigned char *p, int total,
}
fz_pixmap *
-fz_load_bmp(fz_context *ctx, unsigned char *p, int total)
+fz_load_bmp(fz_context *ctx, unsigned char *p, size_t total)
{
struct info bmp;
fz_pixmap *image;
@@ -949,7 +949,7 @@ fz_load_bmp(fz_context *ctx, unsigned char *p, int total)
}
void
-fz_load_bmp_info(fz_context *ctx, unsigned char *p, int total, int *wp, int *hp, int *xresp, int *yresp, fz_colorspace **cspacep)
+fz_load_bmp_info(fz_context *ctx, unsigned char *p, size_t total, int *wp, int *hp, int *xresp, int *yresp, fz_colorspace **cspacep)
{
struct info bmp;
diff --git a/source/fitz/load-gif.c b/source/fitz/load-gif.c
index 06f353f3..053a4493 100644
--- a/source/fitz/load-gif.c
+++ b/source/fitz/load-gif.c
@@ -385,7 +385,7 @@ gif_mask_transparency(fz_context *ctx, fz_pixmap *image, struct info *info)
}
static fz_pixmap *
-gif_read_image(fz_context *ctx, struct info *info, unsigned char *p, int total, int only_metadata)
+gif_read_image(fz_context *ctx, struct info *info, unsigned char *p, size_t total, int only_metadata)
{
fz_pixmap *pix;
unsigned char *end = p + total;
@@ -514,7 +514,7 @@ gif_read_image(fz_context *ctx, struct info *info, unsigned char *p, int total,
}
fz_pixmap *
-fz_load_gif(fz_context *ctx, unsigned char *p, int total)
+fz_load_gif(fz_context *ctx, unsigned char *p, size_t total)
{
fz_pixmap *image;
struct info gif;
@@ -527,7 +527,7 @@ fz_load_gif(fz_context *ctx, unsigned char *p, int total)
}
void
-fz_load_gif_info(fz_context *ctx, unsigned char *p, int total, int *wp, int *hp, int *xresp, int *yresp, fz_colorspace **cspacep)
+fz_load_gif_info(fz_context *ctx, unsigned char *p, size_t total, int *wp, int *hp, int *xresp, int *yresp, fz_colorspace **cspacep)
{
struct info gif;
diff --git a/source/fitz/load-jpeg.c b/source/fitz/load-jpeg.c
index 1a155191..40fcef51 100644
--- a/source/fitz/load-jpeg.c
+++ b/source/fitz/load-jpeg.c
@@ -215,7 +215,7 @@ static int extract_app13_resolution(jpeg_saved_marker_ptr marker, int *xres, int
}
fz_pixmap *
-fz_load_jpeg(fz_context *ctx, unsigned char *rbuf, int rlen)
+fz_load_jpeg(fz_context *ctx, unsigned char *rbuf, size_t rlen)
{
struct jpeg_decompress_struct cinfo;
struct jpeg_error_mgr err;
@@ -329,7 +329,7 @@ fz_load_jpeg(fz_context *ctx, unsigned char *rbuf, int rlen)
}
void
-fz_load_jpeg_info(fz_context *ctx, unsigned char *rbuf, int rlen, int *xp, int *yp, int *xresp, int *yresp, fz_colorspace **cspacep)
+fz_load_jpeg_info(fz_context *ctx, unsigned char *rbuf, size_t rlen, int *xp, int *yp, int *xresp, int *yresp, fz_colorspace **cspacep)
{
struct jpeg_decompress_struct cinfo;
struct jpeg_error_mgr err;
diff --git a/source/fitz/load-jpx.c b/source/fitz/load-jpx.c
index bcbdaaf3..ab0fb822 100644
--- a/source/fitz/load-jpx.c
+++ b/source/fitz/load-jpx.c
@@ -30,21 +30,19 @@ static void fz_opj_info_callback(const char *msg, void *client_data)
typedef struct stream_block_s
{
unsigned char *data;
- int size;
- int pos;
+ OPJ_SIZE_T size;
+ OPJ_SIZE_T pos;
} stream_block;
static OPJ_SIZE_T fz_opj_stream_read(void * p_buffer, OPJ_SIZE_T p_nb_bytes, void * p_user_data)
{
stream_block *sb = (stream_block *)p_user_data;
- int len;
+ OPJ_SIZE_T len;
len = sb->size - sb->pos;
- if (len < 0)
- len = 0;
if (len == 0)
return (OPJ_SIZE_T)-1; /* End of file! */
- if ((OPJ_SIZE_T)len > p_nb_bytes)
+ if (len > p_nb_bytes)
len = p_nb_bytes;
memcpy(p_buffer, sb->data + sb->pos, len);
sb->pos += len;
@@ -55,8 +53,8 @@ static OPJ_OFF_T fz_opj_stream_skip(OPJ_OFF_T skip, void * p_user_data)
{
stream_block *sb = (stream_block *)p_user_data;
- if (skip > sb->size - sb->pos)
- skip = sb->size - sb->pos;
+ if (skip > (OPJ_OFF_T)(sb->size - sb->pos))
+ skip = (OPJ_OFF_T)(sb->size - sb->pos);
sb->pos += skip;
return sb->pos;
}
@@ -65,14 +63,14 @@ static OPJ_BOOL fz_opj_stream_seek(OPJ_OFF_T seek_pos, void * p_user_data)
{
stream_block *sb = (stream_block *)p_user_data;
- if (seek_pos > sb->size)
+ if (seek_pos > (OPJ_OFF_T)sb->size)
return OPJ_FALSE;
sb->pos = seek_pos;
return OPJ_TRUE;
}
fz_pixmap *
-fz_load_jpx(fz_context *ctx, unsigned char *data, int size, fz_colorspace *defcs, int indexed)
+fz_load_jpx(fz_context *ctx, unsigned char *data, size_t size, fz_colorspace *defcs, int indexed)
{
fz_pixmap *img;
opj_dparameters_t params;
diff --git a/source/fitz/load-jxr.c b/source/fitz/load-jxr.c
index 00c0568f..c898ef18 100644
--- a/source/fitz/load-jxr.c
+++ b/source/fitz/load-jxr.c
@@ -3,13 +3,13 @@
/* TODO: implement JPEG-XR support */
fz_pixmap *
-fz_load_jxr(fz_context *ctx, unsigned char *data, int size)
+fz_load_jxr(fz_context *ctx, unsigned char *data, size_t size)
{
fz_throw(ctx, FZ_ERROR_GENERIC, "JPEG-XR codec is not available");
}
void
-fz_load_jxr_info(fz_context *ctx, unsigned char *data, int size, int *wp, int *hp, int *xresp, int *yresp, fz_colorspace **cspacep)
+fz_load_jxr_info(fz_context *ctx, unsigned char *data, size_t size, int *wp, int *hp, int *xresp, int *yresp, fz_colorspace **cspacep)
{
fz_throw(ctx, FZ_ERROR_GENERIC, "JPEG-XR codec is not available");
}
diff --git a/source/fitz/load-png.c b/source/fitz/load-png.c
index 21e6e94e..74af414e 100644
--- a/source/fitz/load-png.c
+++ b/source/fitz/load-png.c
@@ -367,7 +367,7 @@ png_read_phys(fz_context *ctx, struct info *info, unsigned char *p, unsigned int
}
static void
-png_read_image(fz_context *ctx, struct info *info, unsigned char *p, unsigned int total, int only_metadata)
+png_read_image(fz_context *ctx, struct info *info, unsigned char *p, size_t total, int only_metadata)
{
unsigned int passw[7], passh[7], passofs[8];
unsigned int code, size;
@@ -554,7 +554,7 @@ png_mask_transparency(struct info *info, fz_pixmap *dst)
}
fz_pixmap *
-fz_load_png(fz_context *ctx, unsigned char *p, int total)
+fz_load_png(fz_context *ctx, unsigned char *p, size_t total)
{
fz_pixmap *image;
fz_colorspace *colorspace;
@@ -610,7 +610,7 @@ fz_load_png(fz_context *ctx, unsigned char *p, int total)
}
void
-fz_load_png_info(fz_context *ctx, unsigned char *p, int total, int *wp, int *hp, int *xresp, int *yresp, fz_colorspace **cspacep)
+fz_load_png_info(fz_context *ctx, unsigned char *p, size_t total, int *wp, int *hp, int *xresp, int *yresp, fz_colorspace **cspacep)
{
struct info png;
diff --git a/source/fitz/load-tiff.c b/source/fitz/load-tiff.c
index 292c1b87..821b64e1 100644
--- a/source/fitz/load-tiff.c
+++ b/source/fitz/load-tiff.c
@@ -215,7 +215,7 @@ fz_decode_tiff_jpeg(fz_context *ctx, struct tiff *tiff, fz_stream *chain, unsign
fz_stream *jpegtables = NULL;
int color_transform = -1; /* unset */
if (tiff->jpegtables && (int)tiff->jpegtableslen > 0)
- jpegtables = fz_open_memory(ctx, tiff->jpegtables, (int)tiff->jpegtableslen);
+ jpegtables = fz_open_memory(ctx, tiff->jpegtables, tiff->jpegtableslen);
if (tiff->photometric == 2 /* RGB */ || tiff->photometric == 3 /* RGBPal */)
color_transform = 0;
stm = fz_open_dctd(ctx, chain, color_transform, 0, jpegtables);
@@ -764,7 +764,7 @@ fz_swap_tiff_byte_order(unsigned char *buf, int n)
}
static void
-fz_decode_tiff_header(fz_context *ctx, struct tiff *tiff, unsigned char *buf, int len)
+fz_decode_tiff_header(fz_context *ctx, struct tiff *tiff, unsigned char *buf, size_t len)
{
unsigned version;
@@ -868,7 +868,7 @@ fz_decode_tiff_ifd(fz_context *ctx, struct tiff *tiff)
}
fz_pixmap *
-fz_load_tiff_subimage(fz_context *ctx, unsigned char *buf, int len, int subimage)
+fz_load_tiff_subimage(fz_context *ctx, unsigned char *buf, size_t len, int subimage)
{
fz_pixmap *image;
struct tiff tiff = { 0 };
@@ -932,13 +932,13 @@ fz_load_tiff_subimage(fz_context *ctx, unsigned char *buf, int len, int subimage
}
fz_pixmap *
-fz_load_tiff(fz_context *ctx, unsigned char *buf, int len)
+fz_load_tiff(fz_context *ctx, unsigned char *buf, size_t len)
{
return fz_load_tiff_subimage(ctx, buf, len, 0);
}
void
-fz_load_tiff_info_subimage(fz_context *ctx, unsigned char *buf, int len, int *wp, int *hp, int *xresp, int *yresp, fz_colorspace **cspacep, int subimage)
+fz_load_tiff_info_subimage(fz_context *ctx, unsigned char *buf, size_t len, int *wp, int *hp, int *xresp, int *yresp, fz_colorspace **cspacep, int subimage)
{
struct tiff tiff = { 0 };
@@ -970,13 +970,13 @@ fz_load_tiff_info_subimage(fz_context *ctx, unsigned char *buf, int len, int *wp
}
void
-fz_load_tiff_info(fz_context *ctx, unsigned char *buf, int len, int *wp, int *hp, int *xresp, int *yresp, fz_colorspace **cspacep)
+fz_load_tiff_info(fz_context *ctx, unsigned char *buf, size_t len, int *wp, int *hp, int *xresp, int *yresp, fz_colorspace **cspacep)
{
fz_load_tiff_info_subimage(ctx, buf, len, wp, hp, xresp, yresp, cspacep, 0);
}
int
-fz_load_tiff_subimage_count(fz_context *ctx, unsigned char *buf, int len)
+fz_load_tiff_subimage_count(fz_context *ctx, unsigned char *buf, size_t len)
{
unsigned offset;
unsigned subimage_count = 0;
diff --git a/source/fitz/memory.c b/source/fitz/memory.c
index 94901d1d..4a498e44 100644
--- a/source/fitz/memory.c
+++ b/source/fitz/memory.c
@@ -191,7 +191,7 @@ fz_free(fz_context *ctx, void *p)
char *
fz_strdup(fz_context *ctx, const char *s)
{
- int len = strlen(s) + 1;
+ size_t len = strlen(s) + 1;
char *ns = fz_malloc(ctx, len);
memcpy(ns, s, len);
return ns;
@@ -200,7 +200,7 @@ fz_strdup(fz_context *ctx, const char *s)
char *
fz_strdup_no_throw(fz_context *ctx, const char *s)
{
- int len = strlen(s) + 1;
+ size_t len = strlen(s) + 1;
char *ns = fz_malloc_no_throw(ctx, len);
if (ns)
memcpy(ns, s, len);
diff --git a/source/fitz/output.c b/source/fitz/output.c
index 07422955..0fc4fc09 100644
--- a/source/fitz/output.c
+++ b/source/fitz/output.c
@@ -7,7 +7,7 @@ struct fz_output_context_s
fz_output *err;
};
-static void std_write(fz_context *ctx, void *opaque, const void *buffer, int count);
+static void std_write(fz_context *ctx, void *opaque, const void *buffer, size_t count);
static fz_output fz_stdout_global = {
&fz_stdout_global,
@@ -83,12 +83,12 @@ fz_stderr(fz_context *ctx)
}
static void
-file_write(fz_context *ctx, void *opaque, const void *buffer, int count)
+file_write(fz_context *ctx, void *opaque, const void *buffer, size_t count)
{
FILE *file = opaque;
size_t n;
- if (count < 0)
+ if (count == 0)
return;
if (count == 1)
@@ -100,12 +100,12 @@ file_write(fz_context *ctx, void *opaque, const void *buffer, int count)
}
n = fwrite(buffer, 1, count, file);
- if (n < (size_t)count && ferror(file))
+ if (n < count && ferror(file))
fz_throw(ctx, FZ_ERROR_GENERIC, "cannot fwrite: %s", strerror(errno));
}
static void
-std_write(fz_context *ctx, void *opaque, const void *buffer, int count)
+std_write(fz_context *ctx, void *opaque, const void *buffer, size_t count)
{
FILE *f = opaque == &fz_stdout_global ? stdout : opaque == &fz_stderr_global ? stderr : NULL;
file_write(ctx, f, buffer, count);
@@ -177,7 +177,7 @@ fz_new_output_with_path(fz_context *ctx, const char *filename, int append)
}
static void
-buffer_write(fz_context *ctx, void *opaque, const void *data, int len)
+buffer_write(fz_context *ctx, void *opaque, const void *data, size_t len)
{
fz_buffer *buffer = opaque;
fz_write_buffer(ctx, buffer, data, len);
@@ -243,7 +243,7 @@ void
fz_vprintf(fz_context *ctx, fz_output *out, const char *fmt, va_list old_args)
{
char buffer[256], *p = buffer;
- int len;
+ size_t len;
va_list args;
if (!out) return;
diff --git a/source/fitz/printf.c b/source/fitz/printf.c
index baa1aa3a..8d6bfb0d 100644
--- a/source/fitz/printf.c
+++ b/source/fitz/printf.c
@@ -5,8 +5,8 @@ static const char *fz_hex_digits = "0123456789abcdef";
struct fmtbuf
{
char *p;
- int s;
- int n;
+ size_t s;
+ size_t n;
};
static void fmtputc(struct fmtbuf *out, int c)
@@ -151,8 +151,8 @@ static void fmtquote(struct fmtbuf *out, const char *s, int sq, int eq)
fmtputc(out, eq);
}
-int
-fz_vsnprintf(char *buffer, int space, const char *fmt, va_list args)
+size_t
+fz_vsnprintf(char *buffer, size_t space, const char *fmt, va_list args)
{
struct fmtbuf out;
fz_matrix *m;
@@ -162,7 +162,7 @@ fz_vsnprintf(char *buffer, int space, const char *fmt, va_list args)
int64_t i64;
double f;
char *s;
- int length;
+ size_t length;
out.p = buffer;
out.s = space;
@@ -327,10 +327,10 @@ fz_vsnprintf(char *buffer, int space, const char *fmt, va_list args)
return out.n - 1;
}
-int
-fz_snprintf(char *buffer, int space, const char *fmt, ...)
+size_t
+fz_snprintf(char *buffer, size_t space, const char *fmt, ...)
{
- int n;
+ size_t n;
va_list ap;
va_start(ap, fmt);
n = fz_vsnprintf(buffer, space, fmt, ap);
diff --git a/source/fitz/stext-output.c b/source/fitz/stext-output.c
index c19c5b4b..c7090d33 100644
--- a/source/fitz/stext-output.c
+++ b/source/fitz/stext-output.c
@@ -75,7 +75,7 @@ fz_print_stext_sheet(fz_context *ctx, fz_output *out, fz_stext_sheet *sheet)
static void
send_data_base64(fz_context *ctx, fz_output *out, fz_buffer *buffer)
{
- int i, len;
+ size_t i, len;
static const char set[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
len = buffer->len/3;
diff --git a/source/fitz/store.c b/source/fitz/store.c
index e29aee2d..862c179c 100644
--- a/source/fitz/store.c
+++ b/source/fitz/store.c
@@ -120,7 +120,7 @@ evict(fz_context *ctx, fz_item *item)
fz_lock(ctx, FZ_LOCK_ALLOC);
}
-static int
+static size_t
ensure_space(fz_context *ctx, size_t tofree)
{
fz_item *item, *prev;
@@ -298,7 +298,7 @@ fz_store_item(fz_context *ctx, void *key, void *val_, size_t itemsize, fz_store_
while (size > store->max)
{
/* ensure_space may drop, then retake the lock */
- int saved = ensure_space(ctx, size - store->max);
+ size_t saved = ensure_space(ctx, size - store->max);
size -= saved;
if (saved == 0)
{
diff --git a/source/fitz/stream-open.c b/source/fitz/stream-open.c
index 1b3ce97d..142df7c2 100644
--- a/source/fitz/stream-open.c
+++ b/source/fitz/stream-open.c
@@ -73,13 +73,13 @@ typedef struct fz_file_stream_s
unsigned char buffer[4096];
} fz_file_stream;
-static int next_file(fz_context *ctx, fz_stream *stm, int n)
+static int next_file(fz_context *ctx, fz_stream *stm, size_t n)
{
fz_file_stream *state = stm->state;
/* n is only a hint, that we can safely ignore */
n = fread(state->buffer, 1, sizeof(state->buffer), state->file);
- if (n < 0)
+ if (n < sizeof(state->buffer) && ferror(state->file))
fz_throw(ctx, FZ_ERROR_GENERIC, "read error: %s", strerror(errno));
stm->rp = state->buffer;
stm->wp = state->buffer + n;
@@ -168,7 +168,7 @@ fz_open_file_w(fz_context *ctx, const wchar_t *name)
/* Memory stream */
-static int next_buffer(fz_context *ctx, fz_stream *stm, int max)
+static int next_buffer(fz_context *ctx, fz_stream *stm, size_t max)
{
return EOF;
}
@@ -218,7 +218,7 @@ fz_open_buffer(fz_context *ctx, fz_buffer *buf)
}
fz_stream *
-fz_open_memory(fz_context *ctx, unsigned char *data, int len)
+fz_open_memory(fz_context *ctx, unsigned char *data, size_t len)
{
fz_stream *stm;
diff --git a/source/fitz/stream-prog.c b/source/fitz/stream-prog.c
index 35905e46..042df96f 100644
--- a/source/fitz/stream-prog.c
+++ b/source/fitz/stream-prog.c
@@ -13,10 +13,10 @@ typedef struct prog_state
unsigned char buffer[4096];
} prog_state;
-static int next_prog(fz_context *ctx, fz_stream *stm, int len)
+static int next_prog(fz_context *ctx, fz_stream *stm, size_t len)
{
prog_state *ps = (prog_state *)stm->state;
- int n;
+ size_t n;
unsigned char *buf = ps->buffer;
if (len > sizeof(ps->buffer))
@@ -30,7 +30,7 @@ static int next_prog(fz_context *ctx, fz_stream *stm, int len)
av = ps->length;
ps->available = av;
/* Limit any fetches to be within the data we have */
- if (av < ps->length && len + stm->pos > av)
+ if (av < ps->length && len + stm->pos > (size_t)av)
{
len = av - stm->pos;
if (len <= 0)
@@ -38,8 +38,8 @@ static int next_prog(fz_context *ctx, fz_stream *stm, int len)
}
}
- n = (len > 0 ? fread(buf, 1, (unsigned int)len, ps->file) : 0);
- if (n < 0)
+ n = (len > 0 ? fread(buf, 1, len, ps->file) : 0);
+ if (n < len && ferror(ps->file))
fz_throw(ctx, FZ_ERROR_GENERIC, "read error: %s", strerror(errno));
stm->rp = ps->buffer + stm->pos;
stm->wp = ps->buffer + stm->pos + n;
diff --git a/source/fitz/stream-read.c b/source/fitz/stream-read.c
index 2ace7b1f..b499d68f 100644
--- a/source/fitz/stream-read.c
+++ b/source/fitz/stream-read.c
@@ -2,10 +2,10 @@
#define MIN_BOMB (100 << 20)
-int
-fz_read(fz_context *ctx, fz_stream *stm, unsigned char *buf, int len)
+size_t
+fz_read(fz_context *ctx, fz_stream *stm, unsigned char *buf, size_t len)
{
- int count, n;
+ size_t count, n;
count = 0;
do
@@ -29,9 +29,9 @@ fz_read(fz_context *ctx, fz_stream *stm, unsigned char *buf, int len)
static unsigned char skip_buf[4096];
-int fz_skip(fz_context *ctx, fz_stream *stm, int len)
+size_t fz_skip(fz_context *ctx, fz_stream *stm, size_t len)
{
- int count, l, total = 0;
+ size_t count, l, total = 0;
while (len)
{
@@ -48,16 +48,16 @@ int fz_skip(fz_context *ctx, fz_stream *stm, int len)
}
fz_buffer *
-fz_read_all(fz_context *ctx, fz_stream *stm, int initial)
+fz_read_all(fz_context *ctx, fz_stream *stm, size_t initial)
{
return fz_read_best(ctx, stm, initial, NULL);
}
fz_buffer *
-fz_read_best(fz_context *ctx, fz_stream *stm, int initial, int *truncated)
+fz_read_best(fz_context *ctx, fz_stream *stm, size_t initial, int *truncated)
{
fz_buffer *buf = NULL;
- int n;
+ size_t n;
fz_var(buf);
@@ -110,7 +110,7 @@ fz_read_best(fz_context *ctx, fz_stream *stm, int initial, int *truncated)
}
char *
-fz_read_line(fz_context *ctx, fz_stream *stm, char *mem, int n)
+fz_read_line(fz_context *ctx, fz_stream *stm, char *mem, size_t n)
{
char *s = mem;
int c = EOF;
diff --git a/source/fitz/string.c b/source/fitz/string.c
index de9ee80f..2eb67d4f 100644
--- a/source/fitz/string.c
+++ b/source/fitz/string.c
@@ -30,12 +30,12 @@ fz_strsep(char **stringp, const char *delim)
return ret;
}
-int
-fz_strlcpy(char *dst, const char *src, int siz)
+size_t
+fz_strlcpy(char *dst, const char *src, size_t siz)
{
register char *d = dst;
register const char *s = src;
- register int n = siz;
+ register size_t n = siz;
/* Copy as many bytes as will fit */
if (n != 0 && --n != 0) {
@@ -56,13 +56,13 @@ fz_strlcpy(char *dst, const char *src, int siz)
return(s - src - 1); /* count does not include NUL */
}
-int
-fz_strlcat(char *dst, const char *src, int siz)
+size_t
+fz_strlcat(char *dst, const char *src, size_t siz)
{
register char *d = dst;
register const char *s = src;
- register int n = siz;
- int dlen;
+ register size_t n = siz;
+ size_t dlen;
/* Find the end of dst and adjust bytes left but don't go past end */
while (*d != '\0' && n-- != 0)
@@ -85,9 +85,9 @@ fz_strlcat(char *dst, const char *src, int siz)
}
void
-fz_dirname(char *dir, const char *path, int n)
+fz_dirname(char *dir, const char *path, size_t n)
{
- int i;
+ size_t i;
if (!path || !path[0])
{
@@ -143,7 +143,7 @@ fz_urldecode(char *url)
}
void
-fz_format_output_path(fz_context *ctx, char *path, int size, const char *fmt, int page)
+fz_format_output_path(fz_context *ctx, char *path, size_t size, const char *fmt, int page)
{
const char *s, *p;
char num[40];
diff --git a/source/fitz/svg-device.c b/source/fitz/svg-device.c
index acc2c5bc..9a61fbb0 100644
--- a/source/fitz/svg-device.c
+++ b/source/fitz/svg-device.c
@@ -678,7 +678,7 @@ svg_dev_ignore_text(fz_context *ctx, fz_device *dev, const fz_text *text, const
static void
send_data_base64(fz_context *ctx, fz_output *out, fz_buffer *buffer)
{
- int i, len;
+ size_t i, len;
static const char set[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
len = buffer->len/3;
diff --git a/source/fitz/tempfile.c b/source/fitz/tempfile.c
index 77c7c04a..fd7d0f5f 100644
--- a/source/fitz/tempfile.c
+++ b/source/fitz/tempfile.c
@@ -23,7 +23,7 @@ char *fz_tempfilename(fz_context *ctx, const char *base, const char *hint)
#ifdef USE_HINT_FOR_DIR
char *hintpath;
- int hintlen;
+ size_t hintlen;
hintlen = strlen(hint);
hintpath = fz_malloc(ctx, 1 + hintlen);
diff --git a/source/fitz/unzip.c b/source/fitz/unzip.c
index 21cfa7a5..929c1d5a 100644
--- a/source/fitz/unzip.c
+++ b/source/fitz/unzip.c
@@ -214,24 +214,26 @@ static void read_zip_dir(fz_context *ctx, fz_archive *zip)
{
fz_stream *file = zip->file;
unsigned char buf[512];
- int size, back, maxback;
- int i, n;
+ size_t size, back, maxback;
+ size_t i, n;
fz_seek(ctx, file, 0, SEEK_END);
size = fz_tell(ctx, file);
- maxback = fz_mini(size, 0xFFFF + sizeof buf);
- back = fz_mini(maxback, sizeof buf);
+ maxback = fz_minz(size, 0xFFFF + sizeof buf);
+ back = fz_minz(maxback, sizeof buf);
while (back < maxback)
{
fz_seek(ctx, file, size - back, 0);
n = fz_read(ctx, file, buf, sizeof buf);
+ if (n < 4)
+ break;
for (i = n - 4; i > 0; i--)
{
if (!memcmp(buf + i, "PK\5\6", 4))
{
- read_zip_dir_imp(ctx, zip, size - back + i);
+ read_zip_dir_imp(ctx, zip, (int)(size - back + i));
return;
}
}
diff --git a/source/fitz/writer.c b/source/fitz/writer.c
index 927ddffe..5c82b1d7 100644
--- a/source/fitz/writer.c
+++ b/source/fitz/writer.c
@@ -34,7 +34,7 @@ int
fz_has_option(fz_context *ctx, const char *opts, const char *key, const char **val)
{
const char *straw;
- int n = strlen(key);
+ size_t n = strlen(key);
while ((opts = fz_get_option(ctx, &straw, val, opts)))
if (!strncmp(straw, key, n) && (straw[n] == '=' || straw[n] == ',' || straw[n] == 0))
return 1;
diff --git a/source/fitz/xml.c b/source/fitz/xml.c
index b7804fc4..1621aed2 100644
--- a/source/fitz/xml.c
+++ b/source/fitz/xml.c
@@ -248,10 +248,10 @@ void fz_detach_xml(fz_xml *node)
node->up->down = NULL;
}
-static int xml_parse_entity(int *c, char *a)
+static size_t xml_parse_entity(int *c, char *a)
{
char *b;
- int i;
+ size_t i;
if (a[1] == '#') {
if (a[2] == 'x')
@@ -284,7 +284,7 @@ static int xml_parse_entity(int *c, char *a)
/* We should only be doing this for XHTML, but it shouldn't be a problem. */
for (i = 0; i < nelem(html_entities); ++i) {
- unsigned int n = strlen(html_entities[i].ent);
+ size_t n = strlen(html_entities[i].ent);
if (!memcmp(a+1, html_entities[i].ent, n) && a[1+n] == ';') {
*c = html_entities[i].ucs;
return n + 2;
@@ -585,7 +585,7 @@ parse_attribute_value:
return "end of data in attribute value";
}
-static char *convert_to_utf8(fz_context *doc, unsigned char *s, int n, int *dofree)
+static char *convert_to_utf8(fz_context *doc, unsigned char *s, size_t n, int *dofree)
{
unsigned char *e = s + n;
char *dst, *d;
@@ -626,7 +626,7 @@ static char *convert_to_utf8(fz_context *doc, unsigned char *s, int n, int *dofr
}
fz_xml *
-fz_parse_xml(fz_context *ctx, unsigned char *s, int n, int preserve_white)
+fz_parse_xml(fz_context *ctx, unsigned char *s, size_t n, int preserve_white)
{
struct parser parser;
fz_xml root, *node;
diff --git a/source/fitz/zip.c b/source/fitz/zip.c
index 285fb635..dd67e5ac 100644
--- a/source/fitz/zip.c
+++ b/source/fitz/zip.c
@@ -24,7 +24,7 @@ fz_write_zip_entry(fz_context *ctx, fz_zip_writer *zip, const char *name, fz_buf
int sum;
sum = crc32(0, NULL, 0);
- sum = crc32(sum, buf->data, buf->len);
+ sum = crc32(sum, buf->data, (uInt)buf->len);
fz_write_buffer_int32_le(ctx, zip->central, ZIP_CENTRAL_DIRECTORY_SIG);
fz_write_buffer_int16_le(ctx, zip->central, 0); /* version made by: MS-DOS */
@@ -34,9 +34,9 @@ fz_write_zip_entry(fz_context *ctx, fz_zip_writer *zip, const char *name, fz_buf
fz_write_buffer_int16_le(ctx, zip->central, 0); /* TODO: last mod file time */
fz_write_buffer_int16_le(ctx, zip->central, 0); /* TODO: last mod file date */
fz_write_buffer_int32_le(ctx, zip->central, sum); /* crc-32 */
- fz_write_buffer_int32_le(ctx, zip->central, buf->len); /* csize */
- fz_write_buffer_int32_le(ctx, zip->central, buf->len); /* usize */
- fz_write_buffer_int16_le(ctx, zip->central, strlen(name)); /* file name length */
+ fz_write_buffer_int32_le(ctx, zip->central, (int)buf->len); /* csize */
+ fz_write_buffer_int32_le(ctx, zip->central, (int)buf->len); /* usize */
+ fz_write_buffer_int16_le(ctx, zip->central, (int)strlen(name)); /* file name length */
fz_write_buffer_int16_le(ctx, zip->central, 0); /* extra field length */
fz_write_buffer_int16_le(ctx, zip->central, 0); /* file comment length */
fz_write_buffer_int16_le(ctx, zip->central, 0); /* disk number start */
@@ -52,9 +52,9 @@ fz_write_zip_entry(fz_context *ctx, fz_zip_writer *zip, const char *name, fz_buf
fz_write_int16_le(ctx, zip->output, 0); /* TODO: last mod file time */
fz_write_int16_le(ctx, zip->output, 0); /* TODO: last mod file date */
fz_write_int32_le(ctx, zip->output, sum); /* crc-32 */
- fz_write_int32_le(ctx, zip->output, buf->len); /* csize */
- fz_write_int32_le(ctx, zip->output, buf->len); /* usize */
- fz_write_int16_le(ctx, zip->output, strlen(name)); /* file name length */
+ fz_write_int32_le(ctx, zip->output, (int)buf->len); /* csize */
+ fz_write_int32_le(ctx, zip->output, (int)buf->len); /* usize */
+ fz_write_int16_le(ctx, zip->output, (int)strlen(name)); /* file name length */
fz_write_int16_le(ctx, zip->output, 0); /* extra field length */
fz_write(ctx, zip->output, name, strlen(name));
fz_write(ctx, zip->output, buf->data, buf->len);
@@ -67,7 +67,7 @@ fz_drop_zip_writer(fz_context *ctx, fz_zip_writer *zip)
{
fz_try(ctx)
{
- int offset = fz_tell_output(ctx, zip->output);
+ fz_off_t offset = fz_tell_output(ctx, zip->output);
fz_write(ctx, zip->output, zip->central->data, zip->central->len);
@@ -76,8 +76,8 @@ fz_drop_zip_writer(fz_context *ctx, fz_zip_writer *zip)
fz_write_int16_le(ctx, zip->output, 0); /* number of disk where central directory starts */
fz_write_int16_le(ctx, zip->output, zip->count); /* entries in central directory in this disk */
fz_write_int16_le(ctx, zip->output, zip->count); /* entries in central directory in total */
- fz_write_int32_le(ctx, zip->output, zip->central->len); /* size of the central directory */
- fz_write_int32_le(ctx, zip->output, offset); /* offset of the central directory */
+ fz_write_int32_le(ctx, zip->output, (int)zip->central->len); /* size of the central directory */
+ fz_write_int32_le(ctx, zip->output, (int)offset); /* offset of the central directory */
fz_write_int16_le(ctx, zip->output, 5); /* zip file comment length */
fz_write(ctx, zip->output, "MuPDF", 5);