#endif
}
-uns bread_slow(struct fastbuf *f, void *b, uns l)
+uns bread_slow(struct fastbuf *f, void *b, uns l, uns check)
{
uns total = 0;
while (l)
l -= k;
total += k;
}
+ if (check && total && total != l)
+ die("breadb: short read");
return total;
}
bput5_slow(f, l);
}
-uns bread_slow(struct fastbuf *f, void *b, uns l);
+uns bread_slow(struct fastbuf *f, void *b, uns l, uns check);
static inline uns bread(struct fastbuf *f, void *b, uns l)
{
if (f->bptr + l <= f->bstop)
return l;
}
else
- return bread_slow(f, b, l);
+ return bread_slow(f, b, l, 0);
+}
+
+static inline uns breadb(struct fastbuf *f, void *b, uns l)
+{
+ if (f->bptr + l <= f->bstop)
+ {
+ memcpy(b, f->bptr, l);
+ f->bptr += l;
+ return l;
+ }
+ else
+ return bread_slow(f, b, l, 1);
}
void bwrite_slow(struct fastbuf *f, void *b, uns l);