From 995eaf5dcd982789ccab07c5302bee5d5afea4fc Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Tue, 20 Aug 2002 21:55:59 +0000 Subject: [PATCH] Split bdirect_read to prepare and commit part (similarly to how bdirect_write already works). This allows partial processing of read data. --- lib/fastbuf.c | 9 +++++++-- lib/fastbuf.h | 3 ++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/fastbuf.c b/lib/fastbuf.c index 9f5d3692..013c1b08 100644 --- a/lib/fastbuf.c +++ b/lib/fastbuf.c @@ -288,7 +288,7 @@ bgets0(struct fastbuf *f, byte *b, uns l) } int -bdirect_read(struct fastbuf *f, byte **buf) +bdirect_read_prepare(struct fastbuf *f, byte **buf) { int len; @@ -296,10 +296,15 @@ bdirect_read(struct fastbuf *f, byte **buf) return EOF; *buf = f->bptr; len = f->bstop - f->bptr; - f->bptr += len; return len; } +void +bdirect_read_commit(struct fastbuf *f, byte *pos) +{ + f->bptr = pos; +} + int bdirect_write_prepare(struct fastbuf *f, byte **buf) { diff --git a/lib/fastbuf.h b/lib/fastbuf.h index 3739982c..69df9b71 100644 --- a/lib/fastbuf.h +++ b/lib/fastbuf.h @@ -284,7 +284,8 @@ bputsn(struct fastbuf *f, byte *b) /* Direct I/O on buffers */ -int bdirect_read(struct fastbuf *f, byte **buf); +int bdirect_read_prepare(struct fastbuf *f, byte **buf); +void bdirect_read_commit(struct fastbuf *f, byte *pos); int bdirect_write_prepare(struct fastbuf *f, byte **buf); void bdirect_write_commit(struct fastbuf *f, byte *pos); -- 2.39.2