From 5d1e60c1337bf5b93044957089ab03a3f3eaf334 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Wed, 24 Jan 2018 20:04:03 +0100 Subject: Rename confusing fz_stream close callback to drop. --- include/mupdf/fitz/stream.h | 12 ++++++------ source/fitz/stream-open.c | 22 +++++++++++----------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/include/mupdf/fitz/stream.h b/include/mupdf/fitz/stream.h index 790a0a83..33606cc8 100644 --- a/include/mupdf/fitz/stream.h +++ b/include/mupdf/fitz/stream.h @@ -227,14 +227,14 @@ int fz_stream_meta(fz_context *ctx, fz_stream *stm, int key, int size, void *ptr typedef int (fz_stream_next_fn)(fz_context *ctx, fz_stream *stm, size_t max); /* - fz_stream_close_fn: A function type for use when implementing + fz_stream_drop_fn: A function type for use when implementing fz_streams. The supplied function of this type is called - when the stream is closed, to release the stream specific + when the stream is dropped, to release the stream specific state information. state: The stream state to release. */ -typedef void (fz_stream_close_fn)(fz_context *ctx, void *state); +typedef void (fz_stream_drop_fn)(fz_context *ctx, void *state); /* fz_stream_seek_fn: A function type for use when implementing @@ -267,7 +267,7 @@ struct fz_stream_s unsigned char *rp, *wp; void *state; fz_stream_next_fn *next; - fz_stream_close_fn *close; + fz_stream_drop_fn *drop; fz_stream_seek_fn *seek; fz_stream_meta_fn *meta; }; @@ -282,10 +282,10 @@ struct fz_stream_s data. Return the number of bytes read, or EOF when there is no more data. - close: Should clean up and free the internal state. May not + drop: Should clean up and free the internal state. May not throw exceptions. */ -fz_stream *fz_new_stream(fz_context *ctx, void *state, fz_stream_next_fn *next, fz_stream_close_fn *close); +fz_stream *fz_new_stream(fz_context *ctx, void *state, fz_stream_next_fn *next, fz_stream_drop_fn *drop); fz_stream *fz_keep_stream(fz_context *ctx, fz_stream *stm); diff --git a/source/fitz/stream-open.c b/source/fitz/stream-open.c index 1a99ad52..62e410a4 100644 --- a/source/fitz/stream-open.c +++ b/source/fitz/stream-open.c @@ -25,7 +25,7 @@ fz_file_exists(fz_context *ctx, const char *path) } fz_stream * -fz_new_stream(fz_context *ctx, void *state, fz_stream_next_fn *next, fz_stream_close_fn *close) +fz_new_stream(fz_context *ctx, void *state, fz_stream_next_fn *next, fz_stream_drop_fn *drop) { fz_stream *stm = NULL; @@ -35,7 +35,7 @@ fz_new_stream(fz_context *ctx, void *state, fz_stream_next_fn *next, fz_stream_c } fz_catch(ctx) { - close(ctx, state); + drop(ctx, state); fz_rethrow(ctx); } @@ -52,7 +52,7 @@ fz_new_stream(fz_context *ctx, void *state, fz_stream_next_fn *next, fz_stream_c stm->state = state; stm->next = next; - stm->close = close; + stm->drop = drop; stm->seek = NULL; return stm; @@ -69,8 +69,8 @@ fz_drop_stream(fz_context *ctx, fz_stream *stm) { if (fz_drop_imp(ctx, stm, &stm->refs)) { - if (stm->close) - stm->close(ctx, stm->state); + if (stm->drop) + stm->drop(ctx, stm->state); fz_free(ctx, stm); } } @@ -122,7 +122,7 @@ static void seek_file(fz_context *ctx, fz_stream *stm, int64_t offset, int whenc stm->wp = state->buffer; } -static void close_file(fz_context *ctx, void *state_) +static void drop_file(fz_context *ctx, void *state_) { fz_file_stream *state = state_; int n = fclose(state->file); @@ -138,7 +138,7 @@ fz_open_file_ptr(fz_context *ctx, FILE *file) fz_file_stream *state = fz_malloc_struct(ctx, fz_file_stream); state->file = file; - stm = fz_new_stream(ctx, state, next_file, close_file); + stm = fz_new_stream(ctx, state, next_file, drop_file); stm->seek = seek_file; return stm; @@ -148,7 +148,7 @@ fz_stream *fz_open_file_ptr_no_close(fz_context *ctx, FILE *file) { fz_stream *stm = fz_open_file_ptr(ctx, file); /* We don't own the file ptr. Ensure we don't close it */ - stm->close = NULL; + stm->drop = NULL; return stm; } @@ -204,7 +204,7 @@ static void seek_buffer(fz_context *ctx, fz_stream *stm, int64_t offset, int whe stm->rp += (int)(offset - pos); } -static void close_buffer(fz_context *ctx, void *state_) +static void drop_buffer(fz_context *ctx, void *state_) { fz_buffer *state = (fz_buffer *)state_; fz_drop_buffer(ctx, state); @@ -216,7 +216,7 @@ fz_open_buffer(fz_context *ctx, fz_buffer *buf) fz_stream *stm; fz_keep_buffer(ctx, buf); - stm = fz_new_stream(ctx, buf, next_buffer, close_buffer); + stm = fz_new_stream(ctx, buf, next_buffer, drop_buffer); stm->seek = seek_buffer; stm->rp = buf->data; @@ -232,7 +232,7 @@ fz_open_memory(fz_context *ctx, const unsigned char *data, size_t len) { fz_stream *stm; - stm = fz_new_stream(ctx, NULL, next_buffer, close_buffer); + stm = fz_new_stream(ctx, NULL, next_buffer, drop_buffer); stm->seek = seek_buffer; stm->rp = (unsigned char *)data; -- cgit v1.2.3