diff options
author | Robin Watts <robin.watts@artifex.com> | 2011-09-14 17:36:57 +0100 |
---|---|---|
committer | Robin Watts <Robin.Watts@artifex.com> | 2011-09-15 14:50:17 +0100 |
commit | b51ef0eea028c73b6379e832eaa34fff3fbbb927 (patch) | |
tree | 1ab685ccd356e7fdc832b2e3322c0486b2670cfb /fitz/res_text.c | |
parent | 89ae81f651bfa112b8e07317eb6983beaf7cb212 (diff) | |
download | mupdf-b51ef0eea028c73b6379e832eaa34fff3fbbb927.tar.xz |
Add context to mupdf.
Huge pervasive change to lots of files, adding a context for exception
handling and allocation.
In time we'll move more statics into there.
Also fix some for(i = 0; i < function(...); i++) calls.
Diffstat (limited to 'fitz/res_text.c')
-rw-r--r-- | fitz/res_text.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/fitz/res_text.c b/fitz/res_text.c index d38637f1..1c5bbad0 100644 --- a/fitz/res_text.c +++ b/fitz/res_text.c @@ -1,11 +1,11 @@ #include "fitz.h" fz_text * -fz_new_text(fz_font *font, fz_matrix trm, int wmode) +fz_new_text(fz_context *ctx, fz_font *font, fz_matrix trm, int wmode) { fz_text *text; - text = fz_malloc(sizeof(fz_text)); + text = fz_malloc(ctx, sizeof(fz_text)); text->font = fz_keep_font(font); text->trm = trm; text->wmode = wmode; @@ -17,25 +17,25 @@ fz_new_text(fz_font *font, fz_matrix trm, int wmode) } void -fz_free_text(fz_text *text) +fz_free_text(fz_context *ctx, fz_text *text) { - fz_drop_font(text->font); - fz_free(text->items); - fz_free(text); + fz_drop_font(ctx, text->font); + fz_free(ctx, text->items); + fz_free(ctx, text); } fz_text * -fz_clone_text(fz_text *old) +fz_clone_text(fz_context *ctx, fz_text *old) { fz_text *text; - text = fz_malloc(sizeof(fz_text)); + text = fz_malloc(ctx, sizeof(fz_text)); text->font = fz_keep_font(old->font); text->trm = old->trm; text->wmode = old->wmode; text->len = old->len; text->cap = text->len; - text->items = fz_calloc(text->len, sizeof(fz_text_item)); + text->items = fz_calloc(ctx, text->len, sizeof(fz_text_item)); memcpy(text->items, old->items, text->len * sizeof(fz_text_item)); return text; @@ -91,19 +91,19 @@ fz_bound_text(fz_text *text, fz_matrix ctm) } static void -fz_grow_text(fz_text *text, int n) +fz_grow_text(fz_context *ctx, fz_text *text, int n) { if (text->len + n < text->cap) return; while (text->len + n > text->cap) text->cap = text->cap + 36; - text->items = fz_realloc(text->items, text->cap, sizeof(fz_text_item)); + text->items = fz_realloc(ctx, text->items, text->cap * sizeof(fz_text_item)); } void -fz_add_text(fz_text *text, int gid, int ucs, float x, float y) +fz_add_text(fz_context *ctx, fz_text *text, int gid, int ucs, float x, float y) { - fz_grow_text(text, 1); + fz_grow_text(ctx, text, 1); text->items[text->len].ucs = ucs; text->items[text->len].gid = gid; text->items[text->len].x = x; |