summaryrefslogtreecommitdiff
path: root/source/fitz/error.c
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2016-01-18 14:14:58 +0100
committerTor Andersson <tor.andersson@artifex.com>2016-01-18 14:14:58 +0100
commit254ea37e1f5e3692f6a2fb9a9758f00c75dbca8d (patch)
tree3be8367227d857a274b99136e8f1b64efc7f3b52 /source/fitz/error.c
parent2807e118e4e2fa800ade72872467d8cbc5e9ce2d (diff)
downloadmupdf-254ea37e1f5e3692f6a2fb9a9758f00c75dbca8d.tar.xz
Simplify try/catch macros.
Use a pointer to the top error stack slot instead of access via array and index. Return the stack slot from fz_push_try.
Diffstat (limited to 'source/fitz/error.c')
-rw-r--r--source/fitz/error.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/source/fitz/error.c b/source/fitz/error.c
index a34e5b79..724fd078 100644
--- a/source/fitz/error.c
+++ b/source/fitz/error.c
@@ -82,10 +82,10 @@ void fz_warn(fz_context *ctx, const char *fmt, ...)
FZ_NORETURN static void throw(fz_context *ctx)
{
- if (ctx->error->top >= 0)
+ if (ctx->error->top >= ctx->error->stack)
{
- ctx->error->stack[ctx->error->top].code += 2;
- fz_longjmp(ctx->error->stack[ctx->error->top].buffer, ctx->error->stack[ctx->error->top].code);
+ ctx->error->top->code += 2;
+ fz_longjmp(ctx->error->top->buffer, 1);
}
else
{
@@ -100,15 +100,16 @@ FZ_NORETURN static void throw(fz_context *ctx)
}
}
-void fz_push_try(fz_context *ctx)
+fz_error_stack_slot *fz_push_try(fz_context *ctx)
{
/* If we would overflow the exception stack, throw an exception instead
* of entering the try block. */
- if (ctx->error->top + 1 >= nelem(ctx->error->stack))
+ if (ctx->error->top + 1 >= ctx->error->stack + nelem(ctx->error->stack))
fz_throw(ctx, FZ_ERROR_GENERIC, "exception stack overflow!");
ctx->error->top++;
- ctx->error->stack[ctx->error->top].code = 0;
+ ctx->error->top->code = 0;
+ return ctx->error->top;
}
int fz_caught(fz_context *ctx)