diff options
author | Robin Watts <Robin.Watts@artifex.com> | 2011-10-04 19:51:51 +0100 |
---|---|---|
committer | Robin Watts <Robin.Watts@artifex.com> | 2011-10-04 19:51:51 +0100 |
commit | 1cc3bf432a6d94e6f8411b55ee0f591d098f2062 (patch) | |
tree | ed1d2b0a91f9357b7a7beb1ee730ad62e944c9cd /fitz/base_context.c | |
parent | d208be26537db558edb70236ae517cea31b7ebab (diff) | |
download | mupdf-1cc3bf432a6d94e6f8411b55ee0f591d098f2062.tar.xz |
Reintroduce alloc context section.
This was removed during a previous commit to make the editing easier.
Now added back in.
Diffstat (limited to 'fitz/base_context.c')
-rw-r--r-- | fitz/base_context.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/fitz/base_context.c b/fitz/base_context.c index 66811cf9..c64d09e7 100644 --- a/fitz/base_context.c +++ b/fitz/base_context.c @@ -11,37 +11,39 @@ fz_obj *(*fz_resolve_indirect)(fz_obj*) = fz_resolve_indirect_null; void fz_free_context(fz_context *ctx) { - assert(ctx != NULL); + if (ctx == NULL) + return; /* Other finalisation calls go here (in reverse order) */ if (ctx->error) { assert(ctx->error->top == -1); - free(ctx->error); + fz_free(ctx, ctx->error); } /* Free the context itself */ - free(ctx); + ctx->alloc->free(ctx->alloc->user, ctx); } fz_context * -fz_new_context(void) +fz_new_context(fz_alloc_context *alloc) { fz_context *ctx; - ctx = malloc(sizeof(fz_context)); + ctx = alloc->malloc(alloc->user, sizeof(fz_context)); if (!ctx) return NULL; memset(ctx, 0, sizeof *ctx); + ctx->alloc = alloc; - ctx->error = malloc(sizeof(fz_error_context)); + ctx->error = fz_malloc_no_throw(ctx, sizeof(fz_error_context)); if (!ctx->error) goto cleanup; ctx->error->top = -1; ctx->error->message[0] = 0; - ctx->warn = malloc(sizeof(fz_warn_context)); + ctx->warn = fz_malloc_no_throw(ctx, sizeof(fz_warn_context)); if (!ctx->warn) goto cleanup; ctx->warn->message[0] = 0; @@ -60,5 +62,5 @@ cleanup: fz_context * fz_clone_context(fz_context *ctx) { - return fz_new_context(); + return fz_new_context(ctx->alloc); } |