summaryrefslogtreecommitdiff
path: root/fitz/filt_faxd.c
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2011-12-17 00:07:09 +0000
committerRobin Watts <robin.watts@artifex.com>2011-12-17 00:07:09 +0000
commitc53b6af33c996a7ae6815ac15254297d43f43a9c (patch)
treefb3a9d65ec564cacc60d8a59b2310867ae0926cb /fitz/filt_faxd.c
parent6888c5757779610c9da201e34b70c1800b898616 (diff)
downloadmupdf-c53b6af33c996a7ae6815ac15254297d43f43a9c.tar.xz
Change stream 'close' functions to facilitate error cleanup.
Rather than passing a stream to a close function, just pass context and state - that's all that is required. This enables us to call close to cleanup neatly if the stream fails to allocate.
Diffstat (limited to 'fitz/filt_faxd.c')
-rw-r--r--fitz/filt_faxd.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/fitz/filt_faxd.c b/fitz/filt_faxd.c
index be88eda1..309844bf 100644
--- a/fitz/filt_faxd.c
+++ b/fitz/filt_faxd.c
@@ -643,9 +643,9 @@ rtc:
}
static void
-close_faxd(fz_stream *stm)
+close_faxd(fz_context *ctx, void *state_)
{
- fz_faxd *fax = stm->state;
+ fz_faxd *fax = (fz_faxd *)state_;
int i;
/* if we read any extra bytes, try to put them back */
@@ -654,9 +654,9 @@ close_faxd(fz_stream *stm)
fz_unread_byte(fax->chain);
fz_close(fax->chain);
- fz_free(stm->ctx, fax->ref);
- fz_free(stm->ctx, fax->dst);
- fz_free(stm->ctx, fax);
+ fz_free(ctx, fax->ref);
+ fz_free(ctx, fax->dst);
+ fz_free(ctx, fax);
}
fz_stream *
@@ -665,7 +665,6 @@ fz_open_faxd(fz_stream *chain, fz_obj *params)
fz_faxd *fax;
fz_obj *obj;
fz_context *ctx;
- fz_stream *stream;
assert(chain);
ctx = chain->ctx;
@@ -724,8 +723,6 @@ fz_open_faxd(fz_stream *chain, fz_obj *params)
memset(fax->ref, 0, fax->stride);
memset(fax->dst, 0, fax->stride);
-
- stream = fz_new_stream(ctx, fax, read_faxd, close_faxd);
}
fz_catch(ctx)
{
@@ -734,5 +731,6 @@ fz_open_faxd(fz_stream *chain, fz_obj *params)
fz_free(ctx, fax);
fz_rethrow(ctx);
}
- return stream;
+
+ return fz_new_stream(ctx, fax, read_faxd, close_faxd);
}