[gs-cvs] rev 7629 - in trunk/gs: lib src
lpd at ghostscript.com
lpd at ghostscript.com
Sun Jan 21 09:53:14 PST 2007
Author: lpd
Date: 2007-01-21 09:53:13 -0800 (Sun, 21 Jan 2007)
New Revision: 7629
Modified:
trunk/gs/lib/gs_frsd.ps
trunk/gs/src/zfilter.c
trunk/gs/src/zfrsd.c
Log:
Fixes the ReusableStreamDecode filter so that it allocates the stream in the
correct VM (per the PLRM3), rather than the current VM, even when it is
necessary to read the entire contents of the source into a string. (PS3 CET
23-12W-2) Also fixes filters in general so that they allocate the stream in
the correct VM, rather than always allocating in local VM if the current VM
is local. THIS IS A NON-BACKWARD-COMPATIBLE CHANGE.
Modified: trunk/gs/lib/gs_frsd.ps
===================================================================
--- trunk/gs/lib/gs_frsd.ps 2007-01-21 09:36:41 UTC (rev 7628)
+++ trunk/gs/lib/gs_frsd.ps 2007-01-21 17:53:13 UTC (rev 7629)
@@ -57,15 +57,20 @@
% Make a stream from a procedure or string data source.
0 () .subfiledecode
} if
+ % We must allocate the string in the same VM space as its
+ % source, since the reusable stream must be allocated there.
+ .currentglobal 1 index gcheck .setglobal exch
+ % Stack: dict filters parms CloseSource oldglobal file
10 dict exch {
- % Stack: dict filters parms CloseSource contdict file
+ % Stack: dict filters parms CloseSource oldglobal contdict file
dup 64000 string readstring
3 index dup length 4 -1 roll put not { exit } if
} loop pop
% Concatenate the contents into one big string.
- % Stack: dict filters parms CloseSource contdict
+ % Stack: dict filters parms CloseSource oldglobal contdict
0 1 index { length exch pop add } forall
- dup 65400 gt { .bytestring } { string } ifelse exch {
+ dup 65400 gt { .bytestring } { string } ifelse
+ 3 -1 roll .setglobal exch {
% Stack: dict filters parms CloseSource string index substring
exch 64000 mul exch 2 index 3 1 roll putinterval
} forall
Modified: trunk/gs/src/zfilter.c
===================================================================
--- trunk/gs/src/zfilter.c 2007-01-21 09:36:41 UTC (rev 7628)
+++ trunk/gs/src/zfilter.c 2007-01-21 17:53:13 UTC (rev 7629)
@@ -181,7 +181,8 @@
os_ptr op = osp;
uint min_size = template->min_out_size + max_min_left;
uint save_space = ialloc_space(idmemory);
- uint use_space = max(space, save_space);
+ /* PLRM3 requires the following, *not* max(space, save_space). */
+ uint use_space = max(space, avm_global); /* don't alloc in system space */
os_ptr sop = op - npop;
stream *s;
stream *sstrm;
@@ -260,8 +261,9 @@
os_ptr op = osp;
uint min_size = template->min_in_size + max_min_left;
uint save_space = ialloc_space(idmemory);
- uint use_space = max(space, save_space);
- register os_ptr sop = op - npop;
+ /* PLRM3 requires the following, *not* max(space, save_space). */
+ uint use_space = max(space, avm_global); /* don't alloc in system space */
+ os_ptr sop = op - npop;
stream *s;
stream *sstrm;
bool close = false;
Modified: trunk/gs/src/zfrsd.c
===================================================================
--- trunk/gs/src/zfrsd.c 2007-01-21 09:36:41 UTC (rev 7628)
+++ trunk/gs/src/zfrsd.c 2007-01-21 17:53:13 UTC (rev 7629)
@@ -116,7 +116,7 @@
* ordinary file or string streams.
*/
private int make_rss(i_ctx_t *i_ctx_p, os_ptr op, const byte * data,
- uint size, int space, long offset, long length,
+ uint size, uint space, long offset, long length,
bool is_bytestring);
private int make_rfs(i_ctx_t *i_ctx_p, os_ptr op, stream *fs,
long offset, long length);
@@ -201,14 +201,15 @@
/* Make a reusable string stream. */
private int
make_rss(i_ctx_t *i_ctx_p, os_ptr op, const byte * data, uint size,
- int string_space, long offset, long length, bool is_bytestring)
+ uint string_space, long offset, long length, bool is_bytestring)
{
+ uint save_space = icurrent_space;
stream *s;
long left = min(length, size - offset);
- if (icurrent_space < string_space)
- return_error(e_invalidaccess);
+ ialloc_set_space(idmemory, string_space);
s = file_alloc_stream(imemory, "make_rss");
+ ialloc_set_space(idmemory, save_space);
if (s == 0)
return_error(e_VMerror);
sread_string_reusable(s, data + offset, max(left, 0));
@@ -222,6 +223,8 @@
private int
make_rfs(i_ctx_t *i_ctx_p, os_ptr op, stream *fs, long offset, long length)
{
+ uint save_space = icurrent_space;
+ uint stream_space = imemory_space((const gs_ref_memory_t *)fs->memory);
gs_const_string fname;
gs_parsed_file_name_t pname;
stream *s;
@@ -237,9 +240,11 @@
if (pname.iodev == NULL)
pname.iodev = iodev_default;
/* Open the file again, to be independent of the source. */
+ ialloc_set_space(idmemory, stream_space);
code = file_open_stream((const char *)pname.fname, pname.len, "r",
fs->cbsize, &s, pname.iodev,
pname.iodev->procs.fopen, imemory);
+ ialloc_set_space(idmemory, save_space);
if (code < 0)
return code;
if (sread_subfile(s, offset, length) < 0) {
More information about the gs-cvs
mailing list