diff options
Diffstat (limited to 'source/fitz')
-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 |
8 files changed, 58 insertions, 58 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; |