diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/fitz/compressed-buffer.c | 4 | ||||
-rw-r--r-- | source/fitz/context.c | 2 | ||||
-rw-r--r-- | source/fitz/draw-device.c | 2 | ||||
-rw-r--r-- | source/fitz/function.c | 2 | ||||
-rw-r--r-- | source/fitz/harfbuzz.c | 6 | ||||
-rw-r--r-- | source/fitz/memory.c | 56 | ||||
-rw-r--r-- | source/fitz/pixmap.c | 2 | ||||
-rw-r--r-- | source/fitz/store.c | 42 | ||||
-rw-r--r-- | source/pdf/pdf-cmap-load.c | 2 | ||||
-rw-r--r-- | source/pdf/pdf-shade.c | 2 | ||||
-rw-r--r-- | source/pdf/pdf-store.c | 2 | ||||
-rw-r--r-- | source/pdf/pdf-xobject.c | 2 | ||||
-rw-r--r-- | source/tools/mudraw.c | 17 | ||||
-rw-r--r-- | source/tools/pdfinfo.c | 18 |
14 files changed, 76 insertions, 83 deletions
diff --git a/source/fitz/compressed-buffer.c b/source/fitz/compressed-buffer.c index db1225e4..e2ced271 100644 --- a/source/fitz/compressed-buffer.c +++ b/source/fitz/compressed-buffer.c @@ -73,10 +73,10 @@ fz_open_compressed_buffer(fz_context *ctx, fz_compressed_buffer *buffer) return fz_open_image_decomp_stream_from_buffer(ctx, buffer, &l2factor); } -unsigned int +size_t fz_compressed_buffer_size(fz_compressed_buffer *buffer) { if (!buffer || !buffer->buffer) return 0; - return (unsigned int)buffer->buffer->cap; + return (size_t)buffer->buffer->cap; } diff --git a/source/fitz/context.c b/source/fitz/context.c index 9a533cff..808f53ce 100644 --- a/source/fitz/context.c +++ b/source/fitz/context.c @@ -200,7 +200,7 @@ cleanup: } fz_context * -fz_new_context_imp(const fz_alloc_context *alloc, const fz_locks_context *locks, unsigned int max_store, const char *version) +fz_new_context_imp(const fz_alloc_context *alloc, const fz_locks_context *locks, size_t max_store, const char *version) { fz_context *ctx; diff --git a/source/fitz/draw-device.c b/source/fitz/draw-device.c index 10122b1d..d72b20d0 100644 --- a/source/fitz/draw-device.c +++ b/source/fitz/draw-device.c @@ -1936,7 +1936,7 @@ fz_new_tile_record(fz_context *ctx, fz_pixmap *dest, fz_pixmap *shape) return tile; } -unsigned int +size_t fz_tile_size(fz_context *ctx, tile_record *tile) { if (!tile) diff --git a/source/fitz/function.c b/source/fitz/function.c index 138552ac..dddbd220 100644 --- a/source/fitz/function.c +++ b/source/fitz/function.c @@ -42,7 +42,7 @@ fz_drop_function(fz_context *ctx, fz_function *func) fz_drop_storable(ctx, &func->storable); } -unsigned int +size_t fz_function_size(fz_context *ctx, fz_function *func) { return (func ? func->size : 0); diff --git a/source/fitz/harfbuzz.c b/source/fitz/harfbuzz.c index 30b82c5d..0200c887 100644 --- a/source/fitz/harfbuzz.c +++ b/source/fitz/harfbuzz.c @@ -95,7 +95,7 @@ void *hb_malloc(size_t size) assert(ctx != NULL); - return fz_malloc_no_throw(ctx, (unsigned int)size); + return fz_malloc_no_throw(ctx, size); } void *hb_calloc(size_t n, size_t size) @@ -104,7 +104,7 @@ void *hb_calloc(size_t n, size_t size) assert(ctx != NULL); - return fz_calloc_no_throw(ctx, (unsigned int)n, (unsigned int)size); + return fz_calloc_no_throw(ctx, n, size); } void *hb_realloc(void *ptr, size_t size) @@ -113,7 +113,7 @@ void *hb_realloc(void *ptr, size_t size) assert(ctx != NULL); - return fz_resize_array_no_throw(ctx, ptr, (unsigned int)1, (unsigned int)size); + return fz_resize_array_no_throw(ctx, ptr, 1, size); } void hb_free(void *ptr) diff --git a/source/fitz/memory.c b/source/fitz/memory.c index 15c86cb6..94901d1d 100644 --- a/source/fitz/memory.c +++ b/source/fitz/memory.c @@ -7,7 +7,7 @@ #endif static void * -do_scavenging_malloc(fz_context *ctx, unsigned int size) +do_scavenging_malloc(fz_context *ctx, size_t size) { void *p; int phase = 0; @@ -27,7 +27,7 @@ do_scavenging_malloc(fz_context *ctx, unsigned int size) } static void * -do_scavenging_realloc(fz_context *ctx, void *p, unsigned int size) +do_scavenging_realloc(fz_context *ctx, void *p, size_t size) { void *q; int phase = 0; @@ -47,7 +47,7 @@ do_scavenging_realloc(fz_context *ctx, void *p, unsigned int size) } void * -fz_malloc(fz_context *ctx, unsigned int size) +fz_malloc(fz_context *ctx, size_t size) { void *p; @@ -56,42 +56,42 @@ fz_malloc(fz_context *ctx, unsigned int size) p = do_scavenging_malloc(ctx, size); if (!p) - fz_throw(ctx, FZ_ERROR_OOM, "malloc of %d bytes failed", size); + fz_throw(ctx, FZ_ERROR_OOM, "malloc of " FMT_zu " bytes failed", size); return p; } void * -fz_malloc_no_throw(fz_context *ctx, unsigned int size) +fz_malloc_no_throw(fz_context *ctx, size_t size) { return do_scavenging_malloc(ctx, size); } void * -fz_malloc_array(fz_context *ctx, unsigned int count, unsigned int size) +fz_malloc_array(fz_context *ctx, size_t count, size_t size) { void *p; if (count == 0 || size == 0) return 0; - if (count > UINT_MAX / size) - fz_throw(ctx, FZ_ERROR_OOM, "malloc of array (%d x %d bytes) failed (integer overflow)", count, size); + if (count > SIZE_MAX / size) + fz_throw(ctx, FZ_ERROR_OOM, "malloc of array (" FMT_zu " x " FMT_zu " bytes) failed (size_t overflow)", count, size); p = do_scavenging_malloc(ctx, count * size); if (!p) - fz_throw(ctx, FZ_ERROR_OOM, "malloc of array (%d x %d bytes) failed", count, size); + fz_throw(ctx, FZ_ERROR_OOM, "malloc of array (" FMT_zu " x " FMT_zu " bytes) failed", count, size); return p; } void * -fz_malloc_array_no_throw(fz_context *ctx, unsigned int count, unsigned int size) +fz_malloc_array_no_throw(fz_context *ctx, size_t count, size_t size) { if (count == 0 || size == 0) return 0; - if (count > UINT_MAX / size) + if (count > SIZE_MAX / size) { - fprintf(stderr, "error: malloc of array (%d x %d bytes) failed (integer overflow)", count, size); + fprintf(stderr, "error: malloc of array (" FMT_zu " x " FMT_zu " bytes) failed (size_t overflow)", count, size); return NULL; } @@ -99,38 +99,38 @@ fz_malloc_array_no_throw(fz_context *ctx, unsigned int count, unsigned int size) } void * -fz_calloc(fz_context *ctx, unsigned int count, unsigned int size) +fz_calloc(fz_context *ctx, size_t count, size_t size) { void *p; if (count == 0 || size == 0) return 0; - if (count > UINT_MAX / size) + if (count > SIZE_MAX / size) { - fz_throw(ctx, FZ_ERROR_OOM, "calloc (%d x %d bytes) failed (integer overflow)", count, size); + fz_throw(ctx, FZ_ERROR_OOM, "calloc (" FMT_zu " x " FMT_zu " bytes) failed (size_t overflow)", count, size); } p = do_scavenging_malloc(ctx, count * size); if (!p) { - fz_throw(ctx, FZ_ERROR_OOM, "calloc (%d x %d bytes) failed", count, size); + fz_throw(ctx, FZ_ERROR_OOM, "calloc (" FMT_zu " x " FMT_zu " bytes) failed", count, size); } memset(p, 0, count*size); return p; } void * -fz_calloc_no_throw(fz_context *ctx, unsigned int count, unsigned int size) +fz_calloc_no_throw(fz_context *ctx, size_t count, size_t size) { void *p; if (count == 0 || size == 0) return 0; - if (count > UINT_MAX / size) + if (count > SIZE_MAX / size) { - fprintf(stderr, "error: calloc (%d x %d bytes) failed (integer overflow)\n", count, size); + fprintf(stderr, "error: calloc (" FMT_zu " x " FMT_zu " bytes) failed (size_t overflow)\n", count, size); return NULL; } @@ -143,7 +143,7 @@ fz_calloc_no_throw(fz_context *ctx, unsigned int count, unsigned int size) } void * -fz_resize_array(fz_context *ctx, void *p, unsigned int count, unsigned int size) +fz_resize_array(fz_context *ctx, void *p, size_t count, size_t size) { void *np; @@ -153,17 +153,17 @@ fz_resize_array(fz_context *ctx, void *p, unsigned int count, unsigned int size) return 0; } - if (count > UINT_MAX / size) - fz_throw(ctx, FZ_ERROR_OOM, "resize array (%d x %d bytes) failed (integer overflow)", count, size); + if (count > SIZE_MAX / size) + fz_throw(ctx, FZ_ERROR_OOM, "resize array (" FMT_zu " x " FMT_zu " bytes) failed (size_t overflow)", count, size); np = do_scavenging_realloc(ctx, p, count * size); if (!np) - fz_throw(ctx, FZ_ERROR_OOM, "resize array (%d x %d bytes) failed", count, size); + fz_throw(ctx, FZ_ERROR_OOM, "resize array (" FMT_zu " x " FMT_zu " bytes) failed", count, size); return np; } void * -fz_resize_array_no_throw(fz_context *ctx, void *p, unsigned int count, unsigned int size) +fz_resize_array_no_throw(fz_context *ctx, void *p, size_t count, size_t size) { if (count == 0 || size == 0) { @@ -171,9 +171,9 @@ fz_resize_array_no_throw(fz_context *ctx, void *p, unsigned int count, unsigned return 0; } - if (count > UINT_MAX / size) + if (count > SIZE_MAX / size) { - fprintf(stderr, "error: resize array (%d x %d bytes) failed (integer overflow)\n", count, size); + fprintf(stderr, "error: resize array (" FMT_zu " x " FMT_zu " bytes) failed (size_t overflow)\n", count, size); return NULL; } @@ -208,13 +208,13 @@ fz_strdup_no_throw(fz_context *ctx, const char *s) } static void * -fz_malloc_default(void *opaque, unsigned int size) +fz_malloc_default(void *opaque, size_t size) { return malloc(size); } static void * -fz_realloc_default(void *opaque, void *old, unsigned int size) +fz_realloc_default(void *opaque, void *old, size_t size) { return realloc(old, size); } diff --git a/source/fitz/pixmap.c b/source/fitz/pixmap.c index 17a086c6..8e62b3d5 100644 --- a/source/fitz/pixmap.c +++ b/source/fitz/pixmap.c @@ -1431,7 +1431,7 @@ fz_write_pixmap_as_tga(fz_context *ctx, fz_output *out, fz_pixmap *pixmap, int s fz_write(ctx, out, "\0\0\0\0\0\0\0\0TRUEVISION-XFILE.\0", 26); } -unsigned int +size_t fz_pixmap_size(fz_context *ctx, fz_pixmap * pix) { if (pix == NULL) diff --git a/source/fitz/store.c b/source/fitz/store.c index c80e1087..e29aee2d 100644 --- a/source/fitz/store.c +++ b/source/fitz/store.c @@ -6,7 +6,7 @@ struct fz_item_s { void *key; fz_storable *val; - unsigned int size; + size_t size; fz_item *next; fz_item *prev; fz_store *store; @@ -27,12 +27,12 @@ struct fz_store_s fz_hash_table *hash; /* We keep track of the size of the store, and keep it below max. */ - unsigned int max; - unsigned int size; + size_t max; + size_t size; }; void -fz_new_store_context(fz_context *ctx, unsigned int max) +fz_new_store_context(fz_context *ctx, size_t max) { fz_store *store; store = fz_malloc_struct(ctx, fz_store); @@ -121,10 +121,10 @@ evict(fz_context *ctx, fz_item *item) } static int -ensure_space(fz_context *ctx, unsigned int tofree) +ensure_space(fz_context *ctx, size_t tofree) { fz_item *item, *prev; - unsigned int count; + size_t count; fz_store *store = ctx->store; fz_assert_lock_held(ctx, FZ_LOCK_ALLOC); @@ -208,10 +208,10 @@ touch(fz_store *store, fz_item *item) } void * -fz_store_item(fz_context *ctx, void *key, void *val_, unsigned int itemsize, fz_store_type *type) +fz_store_item(fz_context *ctx, void *key, void *val_, size_t itemsize, fz_store_type *type) { fz_item *item = NULL; - unsigned int size; + size_t size; fz_storable *val = (fz_storable *)val_; fz_store *store = ctx->store; fz_store_hash hash = { NULL }; @@ -525,10 +525,10 @@ fz_print_store(fz_context *ctx, fz_output *out) /* This is now an n^2 algorithm - not ideal, but it'll only be bad if we are * actually managing to scavenge lots of blocks back. */ static int -scavenge(fz_context *ctx, unsigned int tofree) +scavenge(fz_context *ctx, size_t tofree) { fz_store *store = ctx->store; - unsigned int count = 0; + size_t count = 0; fz_item *item, *prev; /* Free the items */ @@ -553,10 +553,10 @@ scavenge(fz_context *ctx, unsigned int tofree) return count != 0; } -int fz_store_scavenge(fz_context *ctx, unsigned int size, int *phase) +int fz_store_scavenge(fz_context *ctx, size_t size, int *phase) { fz_store *store; - unsigned int max; + size_t max; if (ctx == NULL) return 0; @@ -565,13 +565,13 @@ int fz_store_scavenge(fz_context *ctx, unsigned int size, int *phase) return 0; #ifdef DEBUG_SCAVENGING - printf("Scavenging: store=%d size=%d phase=%d\n", store->size, size, *phase); + printf("Scavenging: store=" FMT_zu " size=" FMT_zu " phase=%d\n", store->size, size, *phase); fz_print_store_locked(ctx, stderr); Memento_stats(); #endif do { - unsigned int tofree; + size_t tofree; /* Calculate 'max' as the maximum size of the store for this phase */ if (*phase >= 16) @@ -583,8 +583,8 @@ int fz_store_scavenge(fz_context *ctx, unsigned int size, int *phase) (*phase)++; /* Slightly baroque calculations to avoid overflow */ - if (size > UINT_MAX - store->size) - tofree = UINT_MAX - max; + if (size > SIZE_MAX - store->size) + tofree = SIZE_MAX - max; else if (size + store->size > max) continue; else @@ -593,7 +593,7 @@ int fz_store_scavenge(fz_context *ctx, unsigned int size, int *phase) if (scavenge(ctx, tofree)) { #ifdef DEBUG_SCAVENGING - printf("scavenged: store=%d\n", store->size); + printf("scavenged: store=" FMT_zu "\n", store->size); fz_print_store(ctx, stderr); Memento_stats(); #endif @@ -615,7 +615,7 @@ fz_shrink_store(fz_context *ctx, unsigned int percent) { int success; fz_store *store; - unsigned int new_size; + size_t new_size; if (ctx == NULL) return 0; @@ -628,18 +628,18 @@ fz_shrink_store(fz_context *ctx, unsigned int percent) return 0; #ifdef DEBUG_SCAVENGING - fprintf(stderr, "fz_shrink_store: %d\n", store->size/(1024*1024)); + fprintf(stderr, "fz_shrink_store: " FMT_zu "\n", store->size/(1024*1024)); #endif fz_lock(ctx, FZ_LOCK_ALLOC); - new_size = (unsigned int)(((uint64_t)store->size * percent) / 100); + new_size = (size_t)(((uint64_t)store->size * percent) / 100); if (store->size > new_size) scavenge(ctx, store->size - new_size); success = (store->size <= new_size) ? 1 : 0; fz_unlock(ctx, FZ_LOCK_ALLOC); #ifdef DEBUG_SCAVENGING - fprintf(stderr, "fz_shrink_store after: %d\n", store->size/(1024*1024)); + fprintf(stderr, "fz_shrink_store after: " FMT_zu "\n", store->size/(1024*1024)); #endif return success; diff --git a/source/pdf/pdf-cmap-load.c b/source/pdf/pdf-cmap-load.c index 1c72e139..06359242 100644 --- a/source/pdf/pdf-cmap-load.c +++ b/source/pdf/pdf-cmap-load.c @@ -1,6 +1,6 @@ #include "mupdf/pdf.h" -unsigned int +size_t pdf_cmap_size(fz_context *ctx, pdf_cmap *cmap) { if (cmap == NULL) diff --git a/source/pdf/pdf-shade.c b/source/pdf/pdf-shade.c index 265f3cc0..b8e138c0 100644 --- a/source/pdf/pdf-shade.c +++ b/source/pdf/pdf-shade.c @@ -424,7 +424,7 @@ pdf_load_shading_dict(fz_context *ctx, pdf_document *doc, pdf_obj *dict, const f return shade; } -static unsigned int +static size_t fz_shade_size(fz_shade *s) { if (s == NULL) diff --git a/source/pdf/pdf-store.c b/source/pdf/pdf-store.c index 81dd6f0f..7be7eafe 100644 --- a/source/pdf/pdf-store.c +++ b/source/pdf/pdf-store.c @@ -52,7 +52,7 @@ static fz_store_type pdf_obj_store_type = }; void -pdf_store_item(fz_context *ctx, pdf_obj *key, void *val, unsigned int itemsize) +pdf_store_item(fz_context *ctx, pdf_obj *key, void *val, size_t itemsize) { void *existing; existing = fz_store_item(ctx, key, val, itemsize, &pdf_obj_store_type); diff --git a/source/pdf/pdf-xobject.c b/source/pdf/pdf-xobject.c index 316ca973..cd8418bd 100644 --- a/source/pdf/pdf-xobject.c +++ b/source/pdf/pdf-xobject.c @@ -25,7 +25,7 @@ pdf_drop_xobject_imp(fz_context *ctx, fz_storable *xobj_) fz_free(ctx, xobj); } -static unsigned int +static size_t pdf_xobject_size(pdf_xobject *xobj) { if (xobj == NULL) diff --git a/source/tools/mudraw.c b/source/tools/mudraw.c index 12d5247a..2773d357 100644 --- a/source/tools/mudraw.c +++ b/source/tools/mudraw.c @@ -1242,7 +1242,7 @@ typedef struct } trace_header; static void * -trace_malloc(void *arg, unsigned int size) +trace_malloc(void *arg, size_t size) { trace_header *p; if (size == 0) @@ -1270,7 +1270,7 @@ trace_free(void *arg, void *p_) } static void * -trace_realloc(void *arg, void *p_, unsigned int size) +trace_realloc(void *arg, void *p_, size_t size) { trace_header *p = (trace_header *)p_; size_t oldsize; @@ -1764,16 +1764,9 @@ int mudraw_main(int argc, char **argv) if (showmemory) { -#if defined(_WIN64) -#define FMT "%Iu" -#elif defined(_WIN32) -#define FMT "%u" -#else -#define FMT "%zu" -#endif - fprintf(stderr, "Total memory use = " FMT " bytes\n", memtrace_total); - fprintf(stderr, "Peak memory use = " FMT " bytes\n", memtrace_peak); - fprintf(stderr, "Current memory use = " FMT " bytes\n", memtrace_current); + fprintf(stderr, "Total memory use = " FMT_zu " bytes\n", memtrace_total); + fprintf(stderr, "Peak memory use = " FMT_zu " bytes\n", memtrace_peak); + fprintf(stderr, "Current memory use = " FMT_zu " bytes\n", memtrace_current); } return (errored != 0); diff --git a/source/tools/pdfinfo.c b/source/tools/pdfinfo.c index fd52d12f..9df8e182 100644 --- a/source/tools/pdfinfo.c +++ b/source/tools/pdfinfo.c @@ -668,14 +668,14 @@ printinfo(fz_context *ctx, globals *glo, char *filename, int show, int page) int j; fz_output *out = glo->out; -#define PAGE_FMT "\t%d\t(%d %d R):\t" +#define PAGE_FMT_zu "\t%d\t(%d %d R):\t" if (show & DIMENSIONS && glo->dims > 0) { fz_printf(ctx, out, "Mediaboxes (%d):\n", glo->dims); for (i = 0; i < glo->dims; i++) { - fz_printf(ctx, out, PAGE_FMT "[ %g %g %g %g ]\n", + fz_printf(ctx, out, PAGE_FMT_zu "[ %g %g %g %g ]\n", glo->dim[i].page, pdf_to_num(ctx, glo->dim[i].pageref), pdf_to_gen(ctx, glo->dim[i].pageref), @@ -692,7 +692,7 @@ printinfo(fz_context *ctx, globals *glo, char *filename, int show, int page) fz_printf(ctx, out, "Fonts (%d):\n", glo->fonts); for (i = 0; i < glo->fonts; i++) { - fz_printf(ctx, out, PAGE_FMT "%s '%s' (%d %d R)\n", + fz_printf(ctx, out, PAGE_FMT_zu "%s '%s' (%d %d R)\n", glo->font[i].page, pdf_to_num(ctx, glo->font[i].pageref), pdf_to_gen(ctx, glo->font[i].pageref), @@ -712,7 +712,7 @@ printinfo(fz_context *ctx, globals *glo, char *filename, int show, int page) char *cs = NULL; char *altcs = NULL; - fz_printf(ctx, out, PAGE_FMT "[ ", + fz_printf(ctx, out, PAGE_FMT_zu "[ ", glo->image[i].page, pdf_to_num(ctx, glo->image[i].pageref), pdf_to_gen(ctx, glo->image[i].pageref)); @@ -820,7 +820,7 @@ printinfo(fz_context *ctx, globals *glo, char *filename, int show, int page) "Tensor patch", }; - fz_printf(ctx, out, PAGE_FMT "%s (%d %d R)\n", + fz_printf(ctx, out, PAGE_FMT_zu "%s (%d %d R)\n", glo->shading[i].page, pdf_to_num(ctx, glo->shading[i].pageref), pdf_to_gen(ctx, glo->shading[i].pageref), @@ -852,7 +852,7 @@ printinfo(fz_context *ctx, globals *glo, char *filename, int show, int page) "Constant/fast tiling", }; - fz_printf(ctx, out, PAGE_FMT "Tiling %s %s (%d %d R)\n", + fz_printf(ctx, out, PAGE_FMT_zu "Tiling %s %s (%d %d R)\n", glo->pattern[i].page, pdf_to_num(ctx, glo->pattern[i].pageref), pdf_to_gen(ctx, glo->pattern[i].pageref), @@ -863,7 +863,7 @@ printinfo(fz_context *ctx, globals *glo, char *filename, int show, int page) } else { - fz_printf(ctx, out, PAGE_FMT "Shading %d %d R (%d %d R)\n", + fz_printf(ctx, out, PAGE_FMT_zu "Shading %d %d R (%d %d R)\n", glo->pattern[i].page, pdf_to_num(ctx, glo->pattern[i].pageref), pdf_to_gen(ctx, glo->pattern[i].pageref), @@ -881,7 +881,7 @@ printinfo(fz_context *ctx, globals *glo, char *filename, int show, int page) fz_printf(ctx, out, "Form xobjects (%d):\n", glo->forms); for (i = 0; i < glo->forms; i++) { - fz_printf(ctx, out, PAGE_FMT "Form%s%s%s%s (%d %d R)\n", + fz_printf(ctx, out, PAGE_FMT_zu "Form%s%s%s%s (%d %d R)\n", glo->form[i].page, pdf_to_num(ctx, glo->form[i].pageref), pdf_to_gen(ctx, glo->form[i].pageref), @@ -900,7 +900,7 @@ printinfo(fz_context *ctx, globals *glo, char *filename, int show, int page) fz_printf(ctx, out, "Postscript xobjects (%d):\n", glo->psobjs); for (i = 0; i < glo->psobjs; i++) { - fz_printf(ctx, out, PAGE_FMT "(%d %d R)\n", + fz_printf(ctx, out, PAGE_FMT_zu "(%d %d R)\n", glo->psobj[i].page, pdf_to_num(ctx, glo->psobj[i].pageref), pdf_to_gen(ctx, glo->psobj[i].pageref), |