diff options
author | Chris Liddell <chris.liddell@artifex.com> | 2021-06-10 11:40:23 +0100 |
---|---|---|
committer | Chris Liddell <chris.liddell@artifex.com> | 2021-06-10 11:42:20 +0100 |
commit | 6cf9c3d1631ba370af777ebc4fad18942f8c4196 (patch) | |
tree | 754f419ce026c2dd84f51f644b6c68f1612db1cd /base/stream.c | |
parent | bd56e2ddd62e5706dfafdfe817d71e6d27a7fe49 (diff) | |
download | ghostpdl-6cf9c3d1631ba370af777ebc4fad18942f8c4196.tar.gz |
Add sread_transient_string_reusable()
to match the new sread_transient_string()
Diffstat (limited to 'base/stream.c')
-rw-r--r-- | base/stream.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/base/stream.c b/base/stream.c index 22435e11b..8b48f5f02 100644 --- a/base/stream.c +++ b/base/stream.c @@ -1071,6 +1071,11 @@ s_string_reusable_flush(stream *s) s->cursor.r.ptr = s->cursor.r.limit = s->cbuf + s->bsize - 1; /* just set to the end */ return 0; } + +/* String ownership retained by the caller, for example + Postscript string objects owned by the Postscript + interpreter + */ void sread_string_reusable(stream *s, const byte *ptr, uint len) { @@ -1088,6 +1093,27 @@ sread_string_reusable(stream *s, const byte *ptr, uint len) s->close_at_eod = false; } +/* The string ownership is transferred from caller to stream. + string_mem pointer must be allocator used to allocate the + "string" buffer. + */ +void +sread_transient_string_reusable(stream *s, gs_memory_t *string_mem, const byte *ptr, uint len) +{ + /* + * Note that s->procs.close is s_close_disable, to parallel + * file_close_disable. + */ + static const stream_procs p = { + s_string_available, s_string_read_seek, s_string_reusable_reset, + s_string_reusable_flush, s_close_disable, s_string_read_process + }; + + sread_transient_string(s, string_mem, ptr, len); + s->procs = p; + s->close_at_eod = false; +} + /* Return the number of available bytes when reading from a string. */ static int s_string_available(stream *s, gs_offset_t *pl) |