X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;ds=inline;f=lib%2Ffb-mem.c;h=0de590e04fb90b19cca2c567f2c7c338d75b4180;hb=8ab69f51fccccbcae521bd7f7e3ae27146fd1217;hp=2b0d7e941fa6cf1c9e0e408efe02a3a184bb67d8;hpb=43ad0ca991bb413356651deac398aea6a92eb52d;p=libucw.git diff --git a/lib/fb-mem.c b/lib/fb-mem.c index 2b0d7e94..0de590e0 100644 --- a/lib/fb-mem.c +++ b/lib/fb-mem.c @@ -1,5 +1,5 @@ /* - * Sherlock Library -- Fast Buffered I/O on Memory Streams + * UCW Library -- Fast Buffered I/O on Memory Streams * * (c) 1997--2002 Martin Mares * @@ -10,8 +10,6 @@ #include "lib/lib.h" #include "lib/fastbuf.h" -#include - struct memstream { unsigned blocksize; unsigned uc; @@ -120,6 +118,14 @@ fbmem_seek(struct fastbuf *f, sh_off_t pos, int whence) return; } } + if (!m->first && !pos) + { + /* Seeking to offset 0 in an empty file needs an exception */ + f->buffer = f->bptr = f->bufend = NULL; + f->pos = 0; + FB_MEM(f)->block = NULL; + return; + } die("fbmem_seek to invalid offset"); } @@ -171,6 +177,7 @@ fbmem_clone_read(struct fastbuf *b) f->refill = fbmem_refill; f->seek = fbmem_seek; f->close = fbmem_close; + f->can_overwrite_buffer = 1; return f; }