Hi Dom,
appended patch speeds up escher.c and I can now load
#2393 and #2867 in reasonable time even if
amsofbh->cbLength is bogus.
Robert
Index: support.c
===================================================================
RCS file: /cvsroot/wv/support.c,v
retrieving revision 1.25
diff -u -r1.25 support.c
--- support.c 19 Feb 2002 10:04:51 -0000 1.25
+++ support.c 12 Mar 2002 18:46:18 -0000
@@ -111,6 +111,27 @@
streams = listEntry;
}
+static size_t memorystream_read(MemoryStream *stream, void *buf, size_t count)
+{
+ size_t ret;
+
+ if ( stream->current + count < stream->size)
+ {
+ memcpy(buf, stream->mem + stream->current, count);
+ stream->current += count;
+ ret = count;
+ }
+ else
+ {
+ ret = stream->size - stream->current;
+ memcpy(buf, stream->mem + stream->current, ret);
+ memset(buf + ret , 0, count - ret);
+ stream->current = stream->size;
+ wvTrace(("read out of bounds\n"));
+ }
+ return ret;
+}
+
U32
read_32ubit (wvStream * in)
{
@@ -134,9 +155,7 @@
}
else
{
- ret = *((U32 *) (in->stream.memory_stream->mem +
- in->stream.memory_stream->current));
- in->stream.memory_stream->current +=4;
+ memorystream_read(in->stream.memory_stream, &ret, 4);
}
#endif
return (ret);
@@ -165,9 +184,7 @@
}
else
{
- ret = *((U16 *) (in->stream.memory_stream->mem +
- in->stream.memory_stream->current));
- in->stream.memory_stream->current+=2;
+ memorystream_read(in->stream.memory_stream, &ret, 2);
}
@@ -192,9 +209,7 @@
else
{
U8 ret;
- ret = *((U8 *)(in->stream.memory_stream->mem +
- in->stream.memory_stream->current));
- in->stream.memory_stream->current++;
+ memorystream_read(in->stream.memory_stream, &ret, 1);
return ret;
}
}
@@ -213,9 +228,7 @@
}
else
{
- memcpy(ptr, in->stream.memory_stream->mem +
- in->stream.memory_stream->current,size * nmemb);
- in->stream.memory_stream->current+=size* nmemb;
+ return memorystream_read(in->stream.memory_stream, ptr, size * nmemb);
return size * nmemb;
}
}