]> mj.ucw.cz Git - libucw.git/commitdiff
Added bskip() which skips the given number of bytes by reading.
authorMartin Mares <mj@ucw.cz>
Sun, 27 Jun 2004 13:44:15 +0000 (13:44 +0000)
committerMartin Mares <mj@ucw.cz>
Sun, 27 Jun 2004 13:44:15 +0000 (13:44 +0000)
In the future, we can optimize it by seeking when possible.

lib/fastbuf.c
lib/fastbuf.h

index bf887a18f86acd33ae61603a62486b5a2fbf34b5..d2e08f8648def7918c8fc04404f530aa18fabd0b 100644 (file)
@@ -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;
+    }
+}
index fbaab94a8b0f652b090fc01b166fec1102304418..9e974cf54ea4539b7c6d9f29d19b970f42c17246 100644 (file)
@@ -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)
 {