summaryrefslogtreecommitdiff
path: root/fitz
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2011-09-21 17:29:51 +0200
committerTor Andersson <tor.andersson@artifex.com>2011-09-21 17:29:51 +0200
commitf783c31203be2dbd7a28c89557014f97a367bec9 (patch)
tree8faea8d21fa44b99226af34a13f33c6a0e1f7182 /fitz
parentaa7668835afffd5a2a496a60ed6edb672f5af1a7 (diff)
downloadmupdf-f783c31203be2dbd7a28c89557014f97a367bec9.tar.xz
Add warning context.
Diffstat (limited to 'fitz')
-rw-r--r--fitz/base_context.c7
-rw-r--r--fitz/base_error.c64
-rw-r--r--fitz/base_hash.c27
-rw-r--r--fitz/base_object.c24
-rw-r--r--fitz/dev_text.c2
-rw-r--r--fitz/filt_basic.c2
-rw-r--r--fitz/filt_dctd.c4
-rw-r--r--fitz/filt_flate.c8
-rw-r--r--fitz/filt_jpxd.c2
-rw-r--r--fitz/filt_lzwd.c2
-rw-r--r--fitz/filt_predict.c2
-rw-r--r--fitz/fitz.h37
-rw-r--r--fitz/res_colorspace.c62
-rw-r--r--fitz/res_font.c58
-rw-r--r--fitz/res_path.c8
-rw-r--r--fitz/res_pixmap.c2
-rw-r--r--fitz/stm_open.c4
-rw-r--r--fitz/stm_read.c4
18 files changed, 160 insertions, 159 deletions
diff --git a/fitz/base_context.c b/fitz/base_context.c
index bce0cba1..66811cf9 100644
--- a/fitz/base_context.c
+++ b/fitz/base_context.c
@@ -33,6 +33,7 @@ fz_new_context(void)
ctx = malloc(sizeof(fz_context));
if (!ctx)
return NULL;
+ memset(ctx, 0, sizeof *ctx);
ctx->error = malloc(sizeof(fz_error_context));
if (!ctx->error)
@@ -40,6 +41,12 @@ fz_new_context(void)
ctx->error->top = -1;
ctx->error->message[0] = 0;
+ ctx->warn = malloc(sizeof(fz_warn_context));
+ if (!ctx->warn)
+ goto cleanup;
+ ctx->warn->message[0] = 0;
+ ctx->warn->count = 0;
+
/* New initialisation calls for context entries go here */
return ctx;
diff --git a/fitz/base_error.c b/fitz/base_error.c
index 6963a69b..3ef69a60 100644
--- a/fitz/base_error.c
+++ b/fitz/base_error.c
@@ -1,40 +1,34 @@
#include "fitz.h"
-/* Warning context
- * TODO: move into fz_context
- */
-enum { LINE_LEN = 160, LINE_COUNT = 25 };
+/* Warning context */
-static char warn_message[LINE_LEN] = "";
-static int warn_count = 0;
-
-void fz_flush_warnings(void)
+void fz_flush_warnings(fz_context *ctx)
{
- if (warn_count > 1)
- fprintf(stderr, "warning: ... repeated %d times ...\n", warn_count);
- warn_message[0] = 0;
- warn_count = 0;
+ if (ctx->warn->count > 1)
+ fprintf(stderr, "warning: ... repeated %d times ...\n", ctx->warn->count);
+ ctx->warn->message[0] = 0;
+ ctx->warn->count = 0;
}
-void fz_warn(char *fmt, ...)
+void fz_warn(fz_context *ctx, char *fmt, ...)
{
va_list ap;
- char buf[LINE_LEN];
+ char buf[sizeof ctx->warn->message];
va_start(ap, fmt);
vsnprintf(buf, sizeof buf, fmt, ap);
va_end(ap);
- if (!strcmp(buf, warn_message))
+ if (!strcmp(buf, ctx->warn->message))
{
- warn_count++;
+ ctx->warn->count++;
}
else
{
- fz_flush_warnings();
+ fz_flush_warnings(ctx);
fprintf(stderr, "warning: %s\n", buf);
- fz_strlcpy(warn_message, buf, sizeof warn_message);
- warn_count = 1;
+ fz_strlcpy(ctx->warn->message, buf, sizeof ctx->warn->message);
+ ctx->warn->count = 1;
}
}
@@ -87,43 +81,29 @@ void fz_rethrow(fz_context *ctx)
/* Deprecated error bubbling */
-static char error_message[LINE_COUNT][LINE_LEN];
-static int error_count = 0;
-
static void
fz_emit_error(char what, char *location, char *message)
{
- fz_flush_warnings();
-
fprintf(stderr, "%c %s%s\n", what, location, message);
-
- if (error_count < LINE_COUNT)
- {
- fz_strlcpy(error_message[error_count], location, LINE_LEN);
- fz_strlcat(error_message[error_count], message, LINE_LEN);
- error_count++;
- }
}
int
fz_get_error_count(void)
{
- return error_count;
+ return 0;
}
char *
fz_get_error_line(int n)
{
- return error_message[n];
+ return "";
}
fz_error
fz_error_make_imp(const char *file, int line, const char *func, char *fmt, ...)
{
va_list ap;
- char one[LINE_LEN], two[LINE_LEN];
-
- error_count = 0;
+ char one[256], two[256];
snprintf(one, sizeof one, "%s:%d: %s(): ", file, line, func);
va_start(ap, fmt);
@@ -139,7 +119,7 @@ fz_error
fz_error_note_imp(const char *file, int line, const char *func, fz_error cause, char *fmt, ...)
{
va_list ap;
- char one[LINE_LEN], two[LINE_LEN];
+ char one[256], two[256];
snprintf(one, sizeof one, "%s:%d: %s(): ", file, line, func);
va_start(ap, fmt);
@@ -155,7 +135,7 @@ void
fz_error_handle_imp(const char *file, int line, const char *func, fz_error cause, char *fmt, ...)
{
va_list ap;
- char one[LINE_LEN], two[LINE_LEN];
+ char one[256], two[256];
snprintf(one, sizeof one, "%s:%d: %s(): ", file, line, func);
va_start(ap, fmt);
@@ -169,9 +149,7 @@ fz_error
fz_error_make_impx(char *fmt, ...)
{
va_list ap;
- char buf[LINE_LEN];
-
- error_count = 0;
+ char buf[256];
va_start(ap, fmt);
vsnprintf(buf, sizeof buf, fmt, ap);
@@ -186,7 +164,7 @@ fz_error
fz_error_note_impx(fz_error cause, char *fmt, ...)
{
va_list ap;
- char buf[LINE_LEN];
+ char buf[256];
va_start(ap, fmt);
vsnprintf(buf, sizeof buf, fmt, ap);
@@ -201,7 +179,7 @@ void
fz_error_handle_impx(fz_error cause, char *fmt, ...)
{
va_list ap;
- char buf[LINE_LEN];
+ char buf[256];
va_start(ap, fmt);
vsnprintf(buf, sizeof buf, fmt, ap);
diff --git a/fitz/base_hash.c b/fitz/base_hash.c
index 43bdf2d1..d6ff8ca0 100644
--- a/fitz/base_hash.c
+++ b/fitz/base_hash.c
@@ -19,6 +19,7 @@ struct fz_hash_entry_s
struct fz_hash_table_s
{
+ fz_context *ctx;
int keylen;
int size;
int load;
@@ -49,10 +50,12 @@ fz_new_hash_table(fz_context *ctx, int initialsize, int keylen)
assert(keylen <= MAX_KEY_LEN);
table = fz_malloc(ctx, sizeof(fz_hash_table));
+ table->ctx = ctx;
table->keylen = keylen;
table->size = initialsize;
table->load = 0;
table->ents = fz_malloc_array(ctx, table->size, sizeof(fz_hash_entry));
+ memset(table->ents, 0, sizeof(fz_hash_entry) * table->size);
return table;
}
@@ -83,14 +86,14 @@ fz_hash_get_val(fz_hash_table *table, int idx)
}
void
-fz_free_hash(fz_context *ctx, fz_hash_table *table)
+fz_free_hash(fz_hash_table *table)
{
- fz_free(ctx, table->ents);
- fz_free(ctx, table);
+ fz_free(table->ctx, table->ents);
+ fz_free(table->ctx, table);
}
static void
-fz_resize_hash(fz_context *ctx, fz_hash_table *table, int newsize)
+fz_resize_hash(fz_hash_table *table, int newsize)
{
fz_hash_entry *oldents = table->ents;
int oldsize = table->size;
@@ -99,11 +102,11 @@ fz_resize_hash(fz_context *ctx, fz_hash_table *table, int newsize)
if (newsize < oldload * 8 / 10)
{
- fz_error_make("assert: resize hash too small");
+ fz_warn(table->ctx, "assert: resize hash too small");
return;
}
- table->ents = fz_malloc_array(ctx, newsize, sizeof(fz_hash_entry));
+ table->ents = fz_malloc_array(table->ctx, newsize, sizeof(fz_hash_entry));
memset(table->ents, 0, sizeof(fz_hash_entry) * newsize);
table->size = newsize;
table->load = 0;
@@ -112,11 +115,11 @@ fz_resize_hash(fz_context *ctx, fz_hash_table *table, int newsize)
{
if (oldents[i].val)
{
- fz_hash_insert(ctx, table, oldents[i].key, oldents[i].val);
+ fz_hash_insert(table, oldents[i].key, oldents[i].val);
}
}
- fz_free(ctx, oldents);
+ fz_free(table->ctx, oldents);
}
void *
@@ -139,7 +142,7 @@ fz_hash_find(fz_hash_table *table, void *key)
}
void
-fz_hash_insert(fz_context *ctx, fz_hash_table *table, void *key, void *val)
+fz_hash_insert(fz_hash_table *table, void *key, void *val)
{
fz_hash_entry *ents;
unsigned size;
@@ -147,7 +150,7 @@ fz_hash_insert(fz_context *ctx, fz_hash_table *table, void *key, void *val)
if (table->load > table->size * 8 / 10)
{
- fz_resize_hash(ctx, table, table->size * 2);
+ fz_resize_hash(table, table->size * 2);
}
ents = table->ents;
@@ -165,7 +168,7 @@ fz_hash_insert(fz_context *ctx, fz_hash_table *table, void *key, void *val)
}
if (memcmp(key, ents[pos].key, table->keylen) == 0)
- fz_warn("assert: overwrite hash slot");
+ fz_warn(table->ctx, "assert: overwrite hash slot");
pos = (pos + 1) % size;
}
@@ -183,7 +186,7 @@ fz_hash_remove(fz_hash_table *table, void *key)
{
if (!ents[pos].val)
{
- fz_warn("assert: remove inexistant hash entry");
+ fz_warn(table->ctx, "assert: remove inexistant hash entry");
return;
}
diff --git a/fitz/base_object.c b/fitz/base_object.c
index fd8339a4..fae4b1b4 100644
--- a/fitz/base_object.c
+++ b/fitz/base_object.c
@@ -404,7 +404,7 @@ fz_copy_array(fz_context *ctx, fz_obj *obj)
int n;
if (fz_is_indirect(obj) || !fz_is_array(obj))
- fz_warn("assert: not an array (%s)", fz_objkindstr(obj));
+ fz_warn(obj->ctx, "assert: not an array (%s)", fz_objkindstr(obj));
new = fz_new_array(ctx, fz_array_len(obj));
n = fz_array_len(obj);
@@ -443,11 +443,11 @@ fz_array_put(fz_obj *obj, int i, fz_obj *item)
obj = fz_resolve_indirect(obj);
if (!fz_is_array(obj))
- fz_warn("assert: not an array (%s)", fz_objkindstr(obj));
+ fz_warn(obj->ctx, "assert: not an array (%s)", fz_objkindstr(obj));
else if (i < 0)
- fz_warn("assert: index %d < 0", i);
+ fz_warn(obj->ctx, "assert: index %d < 0", i);
else if (i >= obj->u.a.len)
- fz_warn("assert: index %d > length %d", i, obj->u.a.len);
+ fz_warn(obj->ctx, "assert: index %d > length %d", i, obj->u.a.len);
else
{
if (obj->u.a.items[i])
@@ -462,7 +462,7 @@ fz_array_push(fz_obj *obj, fz_obj *item)
obj = fz_resolve_indirect(obj);
if (!fz_is_array(obj))
- fz_warn("assert: not an array (%s)", fz_objkindstr(obj));
+ fz_warn(obj->ctx, "assert: not an array (%s)", fz_objkindstr(obj));
else
{
if (obj->u.a.len + 1 > obj->u.a.cap)
@@ -484,7 +484,7 @@ fz_array_insert(fz_obj *obj, fz_obj *item)
obj = fz_resolve_indirect(obj);
if (!fz_is_array(obj))
- fz_warn("assert: not an array (%s)", fz_objkindstr(obj));
+ fz_warn(obj->ctx, "assert: not an array (%s)", fz_objkindstr(obj));
else
{
if (obj->u.a.len + 1 > obj->u.a.cap)
@@ -542,7 +542,7 @@ fz_copy_dict(fz_context *ctx, fz_obj *obj)
int i, n;
if (fz_is_indirect(obj) || !fz_is_dict(obj))
- fz_error_make("assert: not a dict (%s)", fz_objkindstr(obj));
+ fz_warn(ctx, "assert: not a dict (%s)", fz_objkindstr(obj));
n = fz_dict_len(obj);
new = fz_new_dict(ctx, n);
@@ -665,7 +665,7 @@ fz_dict_put(fz_obj *obj, fz_obj *key, fz_obj *val)
if (!fz_is_dict(obj))
{
- fz_warn("assert: not a dict (%s)", fz_objkindstr(obj));
+ fz_warn(obj->ctx, "assert: not a dict (%s)", fz_objkindstr(obj));
return;
}
@@ -673,13 +673,13 @@ fz_dict_put(fz_obj *obj, fz_obj *key, fz_obj *val)
s = fz_to_name(key);
else
{
- fz_warn("assert: key is not a name (%s)", fz_objkindstr(obj));
+ fz_warn(obj->ctx, "assert: key is not a name (%s)", fz_objkindstr(obj));
return;
}
if (!val)
{
- fz_warn("assert: val does not exist for key (%s)", s);
+ fz_warn(obj->ctx, "assert: val does not exist for key (%s)", s);
return;
}
@@ -726,7 +726,7 @@ fz_dict_dels(fz_obj *obj, char *key)
obj = fz_resolve_indirect(obj);
if (!fz_is_dict(obj))
- fz_warn("assert: not a dict (%s)", fz_objkindstr(obj));
+ fz_warn(obj->ctx, "assert: not a dict (%s)", fz_objkindstr(obj));
else
{
int i = fz_dict_finds(obj, key);
@@ -747,7 +747,7 @@ fz_dict_del(fz_obj *obj, fz_obj *key)
if (fz_is_name(key))
fz_dict_dels(obj, fz_to_name(key));
else
- fz_warn("assert: key is not a name (%s)", fz_objkindstr(obj));
+ fz_warn(obj->ctx, "assert: key is not a name (%s)", fz_objkindstr(obj));
}
void
diff --git a/fitz/dev_text.c b/fitz/dev_text.c
index bbc8efcb..2e63aa9d 100644
--- a/fitz/dev_text.c
+++ b/fitz/dev_text.c
@@ -239,7 +239,7 @@ fz_text_extract_span(fz_context *ctx, fz_text_span **last, fz_text *text, fz_mat
{
err = FT_Set_Char_Size(font->ft_face, 64, 64, 72, 72);
if (err)
- fz_warn("freetype set character size: %s", ft_error_string(err));
+ fz_warn(ctx, "freetype set character size: %s", ft_error_string(err));
ascender = (float)face->ascender / face->units_per_EM;
descender = (float)face->descender / face->units_per_EM;
}
diff --git a/fitz/filt_basic.c b/fitz/filt_basic.c
index 32fce6f2..0842ec36 100644
--- a/fitz/filt_basic.c
+++ b/fitz/filt_basic.c
@@ -227,7 +227,7 @@ read_a85d(fz_stream *stm, unsigned char *buf, int len)
{
c = fz_read_byte(state->chain);
if (c != '>')
- fz_warn("bad eod marker in a85d");
+ fz_warn(stm->ctx, "bad eod marker in a85d");
switch (count) {
case 0:
diff --git a/fitz/filt_dctd.c b/fitz/filt_dctd.c
index 7efbac91..fb0e77e7 100644
--- a/fitz/filt_dctd.c
+++ b/fitz/filt_dctd.c
@@ -52,7 +52,7 @@ static boolean fill_input_buffer(j_decompress_ptr cinfo)
if (src->bytes_in_buffer == 0)
{
static unsigned char eoi[2] = { 0xFF, JPEG_EOI };
- fz_warn("premature end of file in jpeg");
+ fz_warn(state->ctx, "premature end of file in jpeg");
src->next_input_byte = eoi;
src->bytes_in_buffer = 2;
}
@@ -187,7 +187,7 @@ close_dctd(fz_stream *stm)
if (setjmp(state->jb))
{
state->chain->rp = state->chain->wp - state->cinfo.src->bytes_in_buffer;
- fz_warn("jpeg error: %s", state->msg);
+ fz_warn(state->ctx, "jpeg error: %s", state->msg);
goto skip;
}
diff --git a/fitz/filt_flate.c b/fitz/filt_flate.c
index d9ac44e6..11100c94 100644
--- a/fitz/filt_flate.c
+++ b/fitz/filt_flate.c
@@ -49,12 +49,12 @@ read_flated(fz_stream *stm, unsigned char *outbuf, int outlen)
}
else if (code == Z_BUF_ERROR)
{
- fz_warn("premature end of data in flate filter");
+ fz_warn(stm->ctx, "premature end of data in flate filter");
return outlen - zp->avail_out;
}
else if (code == Z_DATA_ERROR && zp->avail_in == 0)
{
- fz_warn("ignoring zlib error: %s", zp->msg);
+ fz_warn(stm->ctx, "ignoring zlib error: %s", zp->msg);
return outlen - zp->avail_out;
}
else if (code != Z_OK)
@@ -74,7 +74,7 @@ close_flated(fz_stream *stm)
code = inflateEnd(&state->z);
if (code != Z_OK)
- fz_warn("zlib error: inflateEnd: %s", state->z.msg);
+ fz_warn(stm->ctx, "zlib error: inflateEnd: %s", state->z.msg);
fz_close(state->chain);
fz_free(stm->ctx, state);
@@ -97,7 +97,7 @@ fz_open_flated(fz_stream *chain)
code = inflateInit(&state->z);
if (code != Z_OK)
- fz_warn("zlib error: inflateInit: %s", state->z.msg);
+ fz_warn(chain->ctx, "zlib error: inflateInit: %s", state->z.msg);
return fz_new_stream(chain->ctx, state, read_flated, close_flated);
}
diff --git a/fitz/filt_jpxd.c b/fitz/filt_jpxd.c
index 07d6a572..d0d6cdef 100644
--- a/fitz/filt_jpxd.c
+++ b/fitz/filt_jpxd.c
@@ -93,7 +93,7 @@ fz_load_jpx_image(fz_context *ctx, fz_pixmap **imgp, unsigned char *data, int si
}
else
{
- fz_warn("jpx file and dict colorspaces do not match");
+ fz_warn(ctx, "jpx file and dict colorspaces do not match");
defcs = NULL;
}
}
diff --git a/fitz/filt_lzwd.c b/fitz/filt_lzwd.c
index 17d41d94..76cad305 100644
--- a/fitz/filt_lzwd.c
+++ b/fitz/filt_lzwd.c
@@ -104,7 +104,7 @@ read_lzwd(fz_stream *stm, unsigned char *buf, int len)
else if (code == next_code)
table[next_code].value = table[next_code].first_char;
else
- fz_warn("out of range code encountered in lzw decode");
+ fz_warn(stm->ctx, "out of range code encountered in lzw decode");
next_code ++;
diff --git a/fitz/filt_predict.c b/fitz/filt_predict.c
index 266cc033..ed0d6d98 100644
--- a/fitz/filt_predict.c
+++ b/fitz/filt_predict.c
@@ -213,7 +213,7 @@ fz_open_predict(fz_stream *chain, fz_obj *params)
state->predictor != 12 && state->predictor != 13 &&
state->predictor != 14 && state->predictor != 15)
{
- fz_warn("invalid predictor: %d", state->predictor);
+ fz_warn(ctx, "invalid predictor: %d", state->predictor);
state->predictor = 1;
}
diff --git a/fitz/fitz.h b/fitz/fitz.h
index a15304b7..048e1c35 100644
--- a/fitz/fitz.h
+++ b/fitz/fitz.h
@@ -121,9 +121,6 @@ typedef int fz_error;
#define fz_okay ((fz_error)0)
-void fz_warn(char *fmt, ...) __printflike(1, 2);
-void fz_flush_warnings(void);
-
fz_error fz_error_make_imp(const char *file, int line, const char *func, char *fmt, ...) __printflike(4, 5);
fz_error fz_error_note_imp(const char *file, int line, const char *func, fz_error cause, char *fmt, ...) __printflike(5, 6);
void fz_error_handle_imp(const char *file, int line, const char *func, fz_error cause, char *fmt, ...) __printflike(5, 6);
@@ -136,12 +133,20 @@ void fz_error_handle_impx(fz_error cause, char *fmt, ...) __printflike(2, 3);
int fz_get_error_count(void);
char *fz_get_error_line(int n);
-/* Context types */
+/* Contexts */
+typedef struct fz_alloc_context_s fz_alloc_context;
typedef struct fz_error_context_s fz_error_context;
+typedef struct fz_warn_context_s fz_warn_context;
typedef struct fz_context_s fz_context;
-/* Exception context */
+struct fz_alloc_context_s
+{
+ void *user;
+ void *(*malloc)(void *, unsigned int);
+ void *(*realloc)(void *, void *, unsigned int);
+ void *(*free)(void *, void *, unsigned int);
+};
struct fz_error_context_s
{
@@ -166,14 +171,22 @@ struct fz_error_context_s
if (ctx->error->stack[ctx->error->top--].failed)
void fz_push_try(fz_error_context *ex);
-void fz_throw(fz_context *, char *, ...);
+void fz_throw(fz_context *, char *, ...) __printflike(2, 3);
void fz_rethrow(fz_context *);
-/* Fitz per-thread context */
+struct fz_warn_context_s
+{
+ char message[256];
+ int count;
+};
+
+void fz_warn(fz_context *ctx, char *fmt, ...) __printflike(2, 3);
+void fz_flush_warnings(fz_context *ctx);
struct fz_context_s
{
fz_error_context *error;
+ fz_warn_context *warn;
};
fz_context *fz_new_context(void);
@@ -224,10 +237,10 @@ typedef struct fz_hash_table_s fz_hash_table;
fz_hash_table *fz_new_hash_table(fz_context *ctx, int initialsize, int keylen);
void fz_debug_hash(fz_hash_table *table);
void fz_empty_hash(fz_hash_table *table);
-void fz_free_hash(fz_context *ctx, fz_hash_table *table);
+void fz_free_hash(fz_hash_table *table);
void *fz_hash_find(fz_hash_table *table, void *key);
-void fz_hash_insert(fz_context *ctx, fz_hash_table *table, void *key, void *val);
+void fz_hash_insert(fz_hash_table *table, void *key, void *val);
void fz_hash_remove(fz_hash_table *table, void *key);
int fz_hash_len(fz_hash_table *table);
@@ -746,8 +759,8 @@ struct fz_colorspace_s
int refs;
char name[16];
int n;
- void (*to_rgb)(fz_colorspace *, float *src, float *rgb);
- void (*from_rgb)(fz_colorspace *, float *rgb, float *dst);
+ void (*to_rgb)(fz_context *ctx, fz_colorspace *, float *src, float *rgb);
+ void (*from_rgb)(fz_context *ctx, fz_colorspace *, float *rgb, float *dst);
void (*free_data)(fz_context *Ctx, fz_colorspace *);
void *data;
};
@@ -756,7 +769,7 @@ fz_colorspace *fz_new_colorspace(fz_context *ctx, char *name, int n);
fz_colorspace *fz_keep_colorspace(fz_colorspace *colorspace);
void fz_drop_colorspace(fz_context *ctx, fz_colorspace *colorspace);
-void fz_convert_color(fz_colorspace *srcs, float *srcv, fz_colorspace *dsts, float *dstv);
+void fz_convert_color(fz_context *ctx, fz_colorspace *srcs, float *srcv, fz_colorspace *dsts, float *dstv);
void fz_convert_pixmap(fz_context *ctx, fz_pixmap *src, fz_pixmap *dst);
fz_colorspace *fz_find_device_colorspace(char *name);
diff --git a/fitz/res_colorspace.c b/fitz/res_colorspace.c
index 3f5cd47e..85556b62 100644
--- a/fitz/res_colorspace.c
+++ b/fitz/res_colorspace.c
@@ -40,14 +40,14 @@ fz_drop_colorspace(fz_context *ctx, fz_colorspace *cs)
/* Device colorspace definitions */
-static void gray_to_rgb(fz_colorspace *cs, float *gray, float *rgb)
+static void gray_to_rgb(fz_context *ctx, fz_colorspace *cs, float *gray, float *rgb)
{
rgb[0] = gray[0];
rgb[1] = gray[0];
rgb[2] = gray[0];
}
-static void rgb_to_gray(fz_colorspace *cs, float *rgb, float *gray)
+static void rgb_to_gray(fz_context *ctx, fz_colorspace *cs, float *rgb, float *gray)
{
float r = rgb[0];
float g = rgb[1];
@@ -55,28 +55,28 @@ static void rgb_to_gray(fz_colorspace *cs, float *rgb, float *gray)
gray[0] = r * 0.3f + g * 0.59f + b * 0.11f;
}
-static void rgb_to_rgb(fz_colorspace *cs, float *rgb, float *xyz)
+static void rgb_to_rgb(fz_context *ctx, fz_colorspace *cs, float *rgb, float *xyz)
{
xyz[0] = rgb[0];
xyz[1] = rgb[1];
xyz[2] = rgb[2];
}
-static void bgr_to_rgb(fz_colorspace *cs, float *bgr, float *rgb)
+static void bgr_to_rgb(fz_context *ctx, fz_colorspace *cs, float *bgr, float *rgb)
{
rgb[0] = bgr[2];
rgb[1] = bgr[1];
rgb[2] = bgr[0];
}
-static void rgb_to_bgr(fz_colorspace *cs, float *rgb, float *bgr)
+static void rgb_to_bgr(fz_context *ctx, fz_colorspace *cs, float *rgb, float *bgr)
{
bgr[0] = rgb[2];
bgr[1] = rgb[1];
bgr[2] = rgb[0];
}
-static void cmyk_to_rgb(fz_colorspace *cs, float *cmyk, float *rgb)
+static void cmyk_to_rgb(fz_context *ctx, fz_colorspace *cs, float *cmyk, float *rgb)
{
#ifdef SLOWCMYK /* from poppler */
float c = cmyk[0], m = cmyk[1], y = cmyk[2], k = cmyk[3];
@@ -139,7 +139,7 @@ static void cmyk_to_rgb(fz_colorspace *cs, float *cmyk, float *rgb)
#endif
}
-static void rgb_to_cmyk(fz_colorspace *cs, float *rgb, float *cmyk)
+static void rgb_to_cmyk(fz_context *ctx, fz_colorspace *cs, float *rgb, float *cmyk)
{
float c, m, y, k;
c = 1 - rgb[0];
@@ -173,7 +173,7 @@ fz_find_device_colorspace(char *name)
return fz_device_bgr;
if (!strcmp(name, "DeviceCMYK"))
return fz_device_cmyk;
- fz_warn("unknown device colorspace: %s", name);
+ assert(!"unknown device colorspace");
return NULL;
}
@@ -299,7 +299,7 @@ static void fast_cmyk_to_gray(fz_pixmap *src, fz_pixmap *dst)
}
}
-static void fast_cmyk_to_rgb(fz_pixmap *src, fz_pixmap *dst)
+static void fast_cmyk_to_rgb(fz_context *ctx, fz_pixmap *src, fz_pixmap *dst)
{
unsigned char *s = src->samples;
unsigned char *d = dst->samples;
@@ -312,7 +312,7 @@ static void fast_cmyk_to_rgb(fz_pixmap *src, fz_pixmap *dst)
cmyk[1] = s[1] / 255.0f;
cmyk[2] = s[2] / 255.0f;
cmyk[3] = s[3] / 255.0f;
- cmyk_to_rgb(NULL, cmyk, rgb);
+ cmyk_to_rgb(ctx, NULL, cmyk, rgb);
d[0] = rgb[0] * 255;
d[1] = rgb[1] * 255;
d[2] = rgb[2] * 255;
@@ -327,7 +327,7 @@ static void fast_cmyk_to_rgb(fz_pixmap *src, fz_pixmap *dst)
}
}
-static void fast_cmyk_to_bgr(fz_pixmap *src, fz_pixmap *dst)
+static void fast_cmyk_to_bgr(fz_context *ctx, fz_pixmap *src, fz_pixmap *dst)
{
unsigned char *s = src->samples;
unsigned char *d = dst->samples;
@@ -340,7 +340,7 @@ static void fast_cmyk_to_bgr(fz_pixmap *src, fz_pixmap *dst)
cmyk[1] = s[1] / 255.0f;
cmyk[2] = s[2] / 255.0f;
cmyk[3] = s[3] / 255.0f;
- cmyk_to_rgb(NULL, cmyk, rgb);
+ cmyk_to_rgb(ctx, NULL, cmyk, rgb);
d[0] = rgb[2] * 255;
d[1] = rgb[1] * 255;
d[2] = rgb[0] * 255;
@@ -403,7 +403,7 @@ fz_std_conv_pixmap(fz_context *ctx, fz_pixmap *src, fz_pixmap *dst)
srcv[1] = *s++ - 128;
srcv[2] = *s++ - 128;
- fz_convert_color(ss, srcv, ds, dstv);
+ fz_convert_color(ctx, ss, srcv, ds, dstv);
for (k = 0; k < dstn; k++)
*d++ = dstv[k] * 255;
@@ -423,7 +423,7 @@ fz_std_conv_pixmap(fz_context *ctx, fz_pixmap *src, fz_pixmap *dst)
for (k = 0; k < srcn; k++)
srcv[k] = *s++ / 255.0f;
- fz_convert_color(ss, srcv, ds, dstv);
+ fz_convert_color(ctx, ss, srcv, ds, dstv);
for (k = 0; k < dstn; k++)
*d++ = dstv[k] * 255;
@@ -441,7 +441,7 @@ fz_std_conv_pixmap(fz_context *ctx, fz_pixmap *src, fz_pixmap *dst)
for (i = 0; i < 256; i++)
{
srcv[0] = i / 255.0f;
- fz_convert_color(ss, srcv, ds, dstv);
+ fz_convert_color(ctx, ss, srcv, ds, dstv);
for (k = 0; k < dstn; k++)
lookup[i * dstn + k] = dstv[k] * 255;
}
@@ -482,18 +482,18 @@ fz_std_conv_pixmap(fz_context *ctx, fz_pixmap *src, fz_pixmap *dst)
{
for (k = 0; k < srcn; k++)
srcv[k] = *s++ / 255.0f;
- fz_convert_color(ss, srcv, ds, dstv);
+ fz_convert_color(ctx, ss, srcv, ds, dstv);
for (k = 0; k < dstn; k++)
*d++ = dstv[k] * 255;
- fz_hash_insert(ctx, lookup, s - srcn, d - dstn);
+ fz_hash_insert(lookup, s - srcn, d - dstn);
*d++ = *s++;
}
}
}
- fz_free_hash(ctx, lookup);
+ fz_free_hash(lookup);
}
}
@@ -536,8 +536,8 @@ fz_convert_pixmap(fz_context *ctx, fz_pixmap *sp, fz_pixmap *dp)
else if (ss == fz_device_cmyk)
{
if (ds == fz_device_gray) fast_cmyk_to_gray(sp, dp);
- else if (ds == fz_device_bgr) fast_cmyk_to_bgr(sp, dp);
- else if (ds == fz_device_rgb) fast_cmyk_to_rgb(sp, dp);
+ else if (ds == fz_device_bgr) fast_cmyk_to_bgr(ctx, sp, dp);
+ else if (ds == fz_device_rgb) fast_cmyk_to_rgb(ctx, sp, dp);
else fz_std_conv_pixmap(ctx, sp, dp);
}
@@ -547,7 +547,7 @@ fz_convert_pixmap(fz_context *ctx, fz_pixmap *sp, fz_pixmap *dp)
/* Convert a single color */
static void
-fz_std_conv_color(fz_colorspace *srcs, float *srcv, fz_colorspace *dsts, float *dstv)
+fz_std_conv_color(fz_context *ctx, fz_colorspace *srcs, float *srcv, fz_colorspace *dsts, float *dstv)
{
float rgb[3];
int i;
@@ -555,8 +555,8 @@ fz_std_conv_color(fz_colorspace *srcs, float *srcv, fz_colorspace *dsts, float *
if (srcs != dsts)
{
assert(srcs->to_rgb && dsts->from_rgb);
- srcs->to_rgb(srcs, srcv, rgb);
- dsts->from_rgb(dsts, rgb, dstv);
+ srcs->to_rgb(ctx, srcs, srcv, rgb);
+ dsts->from_rgb(ctx, dsts, rgb, dstv);
for (i = 0; i < dsts->n; i++)
dstv[i] = CLAMP(dstv[i], 0, 1);
}
@@ -568,7 +568,7 @@ fz_std_conv_color(fz_colorspace *srcs, float *srcv, fz_colorspace *dsts, float *
}
void
-fz_convert_color(fz_colorspace *ss, float *sv, fz_colorspace *ds, float *dv)
+fz_convert_color(fz_context *ctx, fz_colorspace *ss, float *sv, fz_colorspace *ds, float *dv)
{
if (ss == fz_device_gray)
{
@@ -586,7 +586,7 @@ fz_convert_color(fz_colorspace *ss, float *sv, fz_colorspace *ds, float *dv)
dv[3] = sv[0];
}
else
- fz_std_conv_color(ss, sv, ds, dv);
+ fz_std_conv_color(ctx, ss, sv, ds, dv);
}
else if (ss == fz_device_rgb)
@@ -613,7 +613,7 @@ fz_convert_color(fz_colorspace *ss, float *sv, fz_colorspace *ds, float *dv)
dv[3] = k;
}
else
- fz_std_conv_color(ss, sv, ds, dv);
+ fz_std_conv_color(ctx, ss, sv, ds, dv);
}
else if (ss == fz_device_bgr)
@@ -640,7 +640,7 @@ fz_convert_color(fz_colorspace *ss, float *sv, fz_colorspace *ds, float *dv)
dv[3] = k;
}
else
- fz_std_conv_color(ss, sv, ds, dv);
+ fz_std_conv_color(ctx, ss, sv, ds, dv);
}
else if (ss == fz_device_cmyk)
@@ -655,7 +655,7 @@ fz_convert_color(fz_colorspace *ss, float *sv, fz_colorspace *ds, float *dv)
else if (ds == fz_device_rgb)
{
#ifdef SLOWCMYK
- cmyk_to_rgb(NULL, sv, dv);
+ cmyk_to_rgb(ctx, NULL, sv, dv);
#else
dv[0] = 1 - MIN(sv[0] + sv[3], 1);
dv[1] = 1 - MIN(sv[1] + sv[3], 1);
@@ -666,7 +666,7 @@ fz_convert_color(fz_colorspace *ss, float *sv, fz_colorspace *ds, float *dv)
{
#ifdef SLOWCMYK
float rgb[3];
- cmyk_to_rgb(NULL, sv, rgb);
+ cmyk_to_rgb(ctx, NULL, sv, rgb);
dv[0] = rgb[2];
dv[1] = rgb[1];
dv[2] = rgb[0];
@@ -677,9 +677,9 @@ fz_convert_color(fz_colorspace *ss, float *sv, fz_colorspace *ds, float *dv)
#endif
}
else
- fz_std_conv_color(ss, sv, ds, dv);
+ fz_std_conv_color(ctx, ss, sv, ds, dv);
}
else
- fz_std_conv_color(ss, sv, ds, dv);
+ fz_std_conv_color(ctx, ss, sv, ds, dv);
}
diff --git a/fitz/res_font.c b/fitz/res_font.c
index 0ef7bf20..47e22ff1 100644
--- a/fitz/res_font.c
+++ b/fitz/res_font.c
@@ -4,7 +4,7 @@
#include FT_FREETYPE_H
#include FT_STROKER_H
-static void fz_finalize_freetype(void);
+static void fz_finalize_freetype(fz_context *ctx);
static fz_font *
fz_new_font(fz_context *ctx, char *name)
@@ -77,8 +77,8 @@ fz_drop_font(fz_context *ctx, fz_font *font)
{
fterr = FT_Done_Face((FT_Face)font->ft_face);
if (fterr)
- fz_warn("freetype finalizing face: %s", ft_error_string(fterr));
- fz_finalize_freetype();
+ fz_warn(ctx, "freetype finalizing face: %s", ft_error_string(fterr));
+ fz_finalize_freetype(ctx);
}
if (font->ft_file)
@@ -137,7 +137,7 @@ char *ft_error_string(int err)
}
static fz_error
-fz_init_freetype(void)
+fz_init_freetype(fz_context *ctx)
{
int fterr;
int maj, min, pat;
@@ -157,7 +157,7 @@ fz_init_freetype(void)
{
fterr = FT_Done_FreeType(fz_ftlib);
if (fterr)
- fz_warn("freetype finalizing: %s", ft_error_string(fterr));
+ fz_warn(ctx, "freetype finalizing: %s", ft_error_string(fterr));
return fz_error_make("freetype version too old: %d.%d.%d", maj, min, pat);
}
@@ -166,7 +166,7 @@ fz_init_freetype(void)
}
static void
-fz_finalize_freetype(void)
+fz_finalize_freetype(fz_context *ctx)
{
int fterr;
@@ -174,7 +174,7 @@ fz_finalize_freetype(void)
{
fterr = FT_Done_FreeType(fz_ftlib);
if (fterr)
- fz_warn("freetype finalizing: %s", ft_error_string(fterr));
+ fz_warn(ctx, "freetype finalizing: %s", ft_error_string(fterr));
fz_ftlib = NULL;
}
}
@@ -187,7 +187,7 @@ fz_new_font_from_file(fz_context *ctx, fz_font **fontp, char *path, int index)
fz_font *font;
int fterr;
- error = fz_init_freetype();
+ error = fz_init_freetype(ctx);
if (error)
return fz_error_note(error, "cannot init freetype library");
@@ -214,7 +214,7 @@ fz_new_font_from_memory(fz_context *ctx, fz_font **fontp, unsigned char *data, i
fz_font *font;
int fterr;
- error = fz_init_freetype();
+ error = fz_init_freetype(ctx);
if (error)
return fz_error_note(error, "cannot init freetype library");
@@ -234,7 +234,7 @@ fz_new_font_from_memory(fz_context *ctx, fz_font **fontp, unsigned char *data, i
}
static fz_matrix
-fz_adjust_ft_glyph_width(fz_font *font, int gid, fz_matrix trm)
+fz_adjust_ft_glyph_width(fz_context *ctx, fz_font *font, int gid, fz_matrix trm)
{
/* Fudge the font matrix to stretch the glyph if we've substituted the font. */
if (font->ft_substitute && gid < font->width_count)
@@ -247,12 +247,12 @@ fz_adjust_ft_glyph_width(fz_font *font, int gid, fz_matrix trm)
/* TODO: use FT_Get_Advance */
fterr = FT_Set_Char_Size(font->ft_face, 1000, 1000, 72, 72);
if (fterr)
- fz_warn("freetype setting character size: %s", ft_error_string(fterr));
+ fz_warn(ctx, "freetype setting character size: %s", ft_error_string(fterr));
fterr = FT_Load_Glyph(font->ft_face, gid,
FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP | FT_LOAD_IGNORE_TRANSFORM);
if (fterr)
- fz_warn("freetype failed to load glyph: %s", ft_error_string(fterr));
+ fz_warn(ctx, "freetype failed to load glyph: %s", ft_error_string(fterr));
realw = ((FT_Face)font->ft_face)->glyph->metrics.horiAdvance;
subw = font->width_table[gid];
@@ -318,7 +318,7 @@ fz_render_ft_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix trm)
FT_Vector v;
FT_Error fterr;
- trm = fz_adjust_ft_glyph_width(font, gid, trm);
+ trm = fz_adjust_ft_glyph_width(ctx, font, gid, trm);
if (font->ft_italic)
trm = fz_concat(fz_shear(0.3f, 0), trm);
@@ -340,7 +340,7 @@ fz_render_ft_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix trm)
fterr = FT_Set_Char_Size(face, 65536, 65536, 72, 72); /* should be 64, 64 */
if (fterr)
- fz_warn("freetype setting character size: %s", ft_error_string(fterr));
+ fz_warn(ctx, "freetype setting character size: %s", ft_error_string(fterr));
FT_Set_Transform(face, &m, &v);
if (fz_get_aa_level() == 0)
@@ -356,11 +356,11 @@ fz_render_ft_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix trm)
fterr = FT_Set_Char_Size(face, 64 * scale, 64 * scale, 72, 72);
if (fterr)
- fz_warn("freetype setting character size: %s", ft_error_string(fterr));
+ fz_warn(ctx, "freetype setting character size: %s", ft_error_string(fterr));
FT_Set_Transform(face, &m, &v);
fterr = FT_Load_Glyph(face, gid, FT_LOAD_NO_BITMAP | FT_LOAD_TARGET_MONO);
if (fterr)
- fz_warn("freetype load glyph (gid %d): %s", gid, ft_error_string(fterr));
+ fz_warn(ctx, "freetype load glyph (gid %d): %s", gid, ft_error_string(fterr));
}
else if (font->ft_hint)
{
@@ -373,14 +373,14 @@ fz_render_ft_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix trm)
*/
fterr = FT_Load_Glyph(face, gid, FT_LOAD_NO_BITMAP);
if (fterr)
- fz_warn("freetype load glyph (gid %d): %s", gid, ft_error_string(fterr));
+ fz_warn(ctx, "freetype load glyph (gid %d): %s", gid, ft_error_string(fterr));
}
else
{
fterr = FT_Load_Glyph(face, gid, FT_LOAD_NO_BITMAP | FT_LOAD_NO_HINTING);
if (fterr)
{
- fz_warn("freetype load glyph (gid %d): %s", gid, ft_error_string(fterr));
+ fz_warn(ctx, "freetype load glyph (gid %d): %s", gid, ft_error_string(fterr));
return NULL;
}
}
@@ -395,7 +395,7 @@ fz_render_ft_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix trm)
fterr = FT_Render_Glyph(face->glyph, fz_get_aa_level() > 0 ? FT_RENDER_MODE_NORMAL : FT_RENDER_MODE_MONO);
if (fterr)
{
- fz_warn("freetype render glyph (gid %d): %s", gid, ft_error_string(fterr));
+ fz_warn(ctx, "freetype render glyph (gid %d): %s", gid, ft_error_string(fterr));
return NULL;
}
@@ -416,7 +416,7 @@ fz_render_ft_stroked_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix tr
FT_BitmapGlyph bitmap;
fz_pixmap *pixmap;
- trm = fz_adjust_ft_glyph_width(font, gid, trm);
+ trm = fz_adjust_ft_glyph_width(ctx, font, gid, trm);
if (font->ft_italic)
trm = fz_concat(fz_shear(0.3f, 0), trm);
@@ -431,7 +431,7 @@ fz_render_ft_stroked_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix tr
fterr = FT_Set_Char_Size(face, 65536, 65536, 72, 72); /* should be 64, 64 */
if (fterr)
{
- fz_warn("FT_Set_Char_Size: %s", ft_error_string(fterr));
+ fz_warn(ctx, "FT_Set_Char_Size: %s", ft_error_string(fterr));
return NULL;
}
@@ -440,14 +440,14 @@ fz_render_ft_stroked_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix tr
fterr = FT_Load_Glyph(face, gid, FT_LOAD_NO_BITMAP | FT_LOAD_NO_HINTING);
if (fterr)
{
- fz_warn("FT_Load_Glyph(gid %d): %s", gid, ft_error_string(fterr));
+ fz_warn(ctx, "FT_Load_Glyph(gid %d): %s", gid, ft_error_string(fterr));
return NULL;
}
fterr = FT_Stroker_New(fz_ftlib, &stroker);
if (fterr)
{
- fz_warn("FT_Stroker_New: %s", ft_error_string(fterr));
+ fz_warn(ctx, "FT_Stroker_New: %s", ft_error_string(fterr));
return NULL;
}
@@ -456,7 +456,7 @@ fz_render_ft_stroked_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix tr
fterr = FT_Get_Glyph(face->glyph, &glyph);
if (fterr)
{
- fz_warn("FT_Get_Glyph: %s", ft_error_string(fterr));
+ fz_warn(ctx, "FT_Get_Glyph: %s", ft_error_string(fterr));
FT_Stroker_Done(stroker);
return NULL;
}
@@ -464,7 +464,7 @@ fz_render_ft_stroked_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix tr
fterr = FT_Glyph_Stroke(&glyph, stroker, 1);
if (fterr)
{
- fz_warn("FT_Glyph_Stroke: %s", ft_error_string(fterr));
+ fz_warn(ctx, "FT_Glyph_Stroke: %s", ft_error_string(fterr));
FT_Done_Glyph(glyph);
FT_Stroker_Done(stroker);
return NULL;
@@ -475,7 +475,7 @@ fz_render_ft_stroked_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix tr
fterr = FT_Glyph_To_Bitmap(&glyph, fz_get_aa_level() > 0 ? FT_RENDER_MODE_NORMAL : FT_RENDER_MODE_MONO, 0, 1);
if (fterr)
{
- fz_warn("FT_Glyph_To_Bitmap: %s", ft_error_string(fterr));
+ fz_warn(ctx, "FT_Glyph_To_Bitmap: %s", ft_error_string(fterr));
FT_Done_Glyph(glyph);
return NULL;
}
@@ -539,17 +539,17 @@ fz_render_t3_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix trm, fz_co
if (dev->flags & FZ_CHARPROC_MASK)
{
if (dev->flags & FZ_CHARPROC_COLOR)
- fz_warn("type3 glyph claims to be both masked and colored");
+ fz_warn(ctx, "type3 glyph claims to be both masked and colored");
model = NULL;
}
else if (dev->flags & FZ_CHARPROC_COLOR)
{
if (model == NULL)
- fz_warn("colored type3 glyph wanted in masked context");
+ fz_warn(ctx, "colored type3 glyph wanted in masked context");
}
else
{
- fz_warn("type3 glyph doesn't specify masked or colored");
+ fz_warn(ctx, "type3 glyph doesn't specify masked or colored");
model = NULL; /* Treat as masked */
}
diff --git a/fitz/res_path.c b/fitz/res_path.c
index af5d9f43..cea720e9 100644
--- a/fitz/res_path.c
+++ b/fitz/res_path.c
@@ -60,7 +60,7 @@ fz_lineto(fz_context *ctx, fz_path *path, float x, float y)
{
if (path->len == 0)
{
- fz_warn("lineto with no current point");
+ fz_warn(ctx, "lineto with no current point");
return;
}
grow_path(ctx, path, 3);
@@ -77,7 +77,7 @@ fz_curveto(fz_context *ctx, fz_path *path,
{
if (path->len == 0)
{
- fz_warn("curveto with no current point");
+ fz_warn(ctx, "curveto with no current point");
return;
}
grow_path(ctx, path, 7);
@@ -96,7 +96,7 @@ fz_curvetov(fz_context *ctx, fz_path *path, float x2, float y2, float x3, float
float x1, y1;
if (path->len == 0)
{
- fz_warn("curvetov with no current point");
+ fz_warn(ctx, "curvetov with no current point");
return;
}
x1 = path->items[path->len-2].v;
@@ -115,7 +115,7 @@ fz_closepath(fz_context *ctx, fz_path *path)
{
if (path->len == 0)
{
- fz_warn("closepath with no current point");
+ fz_warn(ctx, "closepath with no current point");
return;
}
grow_path(ctx, path, 1);
diff --git a/fitz/res_pixmap.c b/fitz/res_pixmap.c
index 040ec386..a34933f5 100644
--- a/fitz/res_pixmap.c
+++ b/fitz/res_pixmap.c
@@ -49,7 +49,7 @@ fz_new_pixmap_with_limit(fz_context *ctx, fz_colorspace *colorspace, int w, int
int size = w * h * n;
if (fz_memory_used + size > fz_memory_limit)
{
- fz_warn("pixmap memory exceeds soft limit %dM + %dM > %dM",
+ fz_warn(ctx, "pixmap memory exceeds soft limit %dM + %dM > %dM",
fz_memory_used/(1<<20), size/(1<<20), fz_memory_limit/(1<<20));
return NULL;
}
diff --git a/fitz/stm_open.c b/fitz/stm_open.c
index f06bdc50..18079f4b 100644
--- a/fitz/stm_open.c
+++ b/fitz/stm_open.c
@@ -64,7 +64,7 @@ static void seek_file(fz_stream *stm, int offset, int whence)
{
int n = lseek(*(int*)stm->state, offset, whence);
if (n < 0)
- fz_warn("cannot lseek: %s", strerror(errno));
+ fz_warn(stm->ctx, "cannot lseek: %s", strerror(errno));
stm->pos = n;
stm->rp = stm->bp;
stm->wp = stm->bp;
@@ -74,7 +74,7 @@ static void close_file(fz_stream *stm)
{
int n = close(*(int*)stm->state);
if (n < 0)
- fz_warn("close error: %s", strerror(errno));
+ fz_warn(stm->ctx, "close error: %s", strerror(errno));
fz_free(stm->ctx, stm->state);
}
diff --git a/fitz/stm_read.c b/fitz/stm_read.c
index 062916c5..23f758eb 100644
--- a/fitz/stm_read.c
+++ b/fitz/stm_read.c
@@ -192,11 +192,11 @@ fz_seek(fz_stream *stm, int offset, int whence)
if (whence == 0)
offset -= fz_tell(stm);
if (offset < 0)
- fz_warn("cannot seek backwards");
+ fz_warn(stm->ctx, "cannot seek backwards");
/* dog slow, but rare enough */
while (offset-- > 0)
fz_read_byte(stm);
}
else
- fz_warn("cannot seek");
+ fz_warn(stm->ctx, "cannot seek");
}