From d6279d601cfb3f86e0bbe3fb78b4daa9af824bf3 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Sun, 27 Jun 2004 13:44:15 +0000 Subject: [PATCH] Added bskip() which skips the given number of bytes by reading. In the future, we can optimize it by seeking when possible. --- lib/fastbuf.c | 13 +++++++++++++ lib/fastbuf.h | 1 + 2 files changed, 14 insertions(+) diff --git a/lib/fastbuf.c b/lib/fastbuf.c index bf887a18..d2e08f86 100644 --- a/lib/fastbuf.c +++ b/lib/fastbuf.c @@ -342,3 +342,16 @@ brewind(struct fastbuf *f) bflush(f); bsetpos(f, 0); } + +void +bskip(struct fastbuf *f, uns len) +{ + while (len) + { + byte *buf; + uns l = bdirect_read_prepare(f, &buf); + l = MIN(l, len); + bdirect_read_commit(f, buf+l); + len -= l; + } +} diff --git a/lib/fastbuf.h b/lib/fastbuf.h index fbaab94a..9e974cf5 100644 --- a/lib/fastbuf.h +++ b/lib/fastbuf.h @@ -119,6 +119,7 @@ void bflush(struct fastbuf *f); void bseek(struct fastbuf *f, sh_off_t pos, int whence); void bsetpos(struct fastbuf *f, sh_off_t pos); void brewind(struct fastbuf *f); +void bskip(struct fastbuf *f, uns len); static inline sh_off_t btell(struct fastbuf *f) { -- 2.39.2