diff options
author | Robin Watts <robin.watts@artifex.com> | 2011-12-17 11:16:22 +0000 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2011-12-17 11:16:22 +0000 |
commit | 880ed0a3dd992d4ab6b8f1d73f862fb930dc2eaa (patch) | |
tree | aa2d80d55cc66f9be936ea4d1459130e1d7be258 /draw/draw_device.c | |
parent | b20c8c628feab388f5d9b738326b8fbc35d8a742 (diff) | |
download | mupdf-880ed0a3dd992d4ab6b8f1d73f862fb930dc2eaa.tar.xz |
More Memory Squeezing fixes.
Diffstat (limited to 'draw/draw_device.c')
-rw-r--r-- | draw/draw_device.c | 48 |
1 files changed, 30 insertions, 18 deletions
diff --git a/draw/draw_device.c b/draw/draw_device.c index 0a1cc812..5ee84d4f 100644 --- a/draw/draw_device.c +++ b/draw/draw_device.c @@ -1531,25 +1531,37 @@ fz_draw_free_user(fz_device *devp) fz_device * fz_new_draw_device(fz_context *ctx, fz_glyph_cache *cache, fz_pixmap *dest) { - fz_device *dev; + fz_device *dev = NULL; fz_draw_device *ddev = fz_malloc_struct(ctx, fz_draw_device); - ddev->cache = cache; - ddev->gel = fz_new_gel(ctx); - ddev->dest = dest; - ddev->shape = NULL; - ddev->top = 0; - ddev->blendmode = 0; - ddev->flags = 0; - ddev->ctx = ctx; - ddev->stack = &ddev->init_stack[0]; - ddev->stack_max = STACK_SIZE; - - ddev->scissor.x0 = dest->x; - ddev->scissor.y0 = dest->y; - ddev->scissor.x1 = dest->x + dest->w; - ddev->scissor.y1 = dest->y + dest->h; - - dev = fz_new_device(ctx, ddev); + ddev->gel = NULL; + + fz_var(dev); + fz_try(ctx) + { + ddev->cache = cache; + ddev->gel = fz_new_gel(ctx); + ddev->dest = dest; + ddev->shape = NULL; + ddev->top = 0; + ddev->blendmode = 0; + ddev->flags = 0; + ddev->ctx = ctx; + ddev->stack = &ddev->init_stack[0]; + ddev->stack_max = STACK_SIZE; + + ddev->scissor.x0 = dest->x; + ddev->scissor.y0 = dest->y; + ddev->scissor.x1 = dest->x + dest->w; + ddev->scissor.y1 = dest->y + dest->h; + + dev = fz_new_device(ctx, ddev); + } + fz_catch(ctx) + { + fz_free_gel(ddev->gel); + fz_free(ctx, ddev); + fz_rethrow(ctx); + } dev->free_user = fz_draw_free_user; dev->fill_path = fz_draw_fill_path; |