summaryrefslogtreecommitdiff
path: root/usr.bin/aucat/abuf.c
diff options
context:
space:
mode:
authorAlexandre Ratchov <ratchov@cvs.openbsd.org>2008-08-14 09:39:17 +0000
committerAlexandre Ratchov <ratchov@cvs.openbsd.org>2008-08-14 09:39:17 +0000
commit176ae4d737b11d07d5a98e458c06aae69b507792 (patch)
treeb091913f7883b40fcb046f698c1b70e8960176c8 /usr.bin/aucat/abuf.c
parent733f511cf5bea0e1866aa4cc8b573de6f0979600 (diff)
factor code that discards data from abuf strucure into a single
abuf_rdiscard() routine. Similarly add abuf_wcommit() routine for writing. The purpose is to stop manupulating FIFO pointers in various places outiside abuf.c, its too error prone. No behaviour change. ok jakemsr
Diffstat (limited to 'usr.bin/aucat/abuf.c')
-rw-r--r--usr.bin/aucat/abuf.c29
1 files changed, 22 insertions, 7 deletions
diff --git a/usr.bin/aucat/abuf.c b/usr.bin/aucat/abuf.c
index e79af1199f9..a3143d9ac18 100644
--- a/usr.bin/aucat/abuf.c
+++ b/usr.bin/aucat/abuf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: abuf.c,v 1.2 2008/05/25 21:16:37 ratchov Exp $ */
+/* $OpenBSD: abuf.c,v 1.3 2008/08/14 09:39:16 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -26,12 +26,6 @@
*
* TODO:
*
- * (easy) create abuf_wcommitblk(), abuf_rdiscardblk() instead of tweeking
- * the fifo pointers by hand. But first, find shorter function names...
- *
- * (easy) dont initialize aproc-specific stuff in abuf_new(), let the
- * aproc xxx_new() routines do it
- *
* (hard) make abuf_fill() a boolean depending on whether
* eof is reached. So the caller can do:
*
@@ -107,6 +101,27 @@ abuf_rgetblk(struct abuf *buf, unsigned *rsize, unsigned ofs)
}
/*
+ * Discard the block at the start postion
+ */
+void
+abuf_rdiscard(struct abuf *buf, unsigned count)
+{
+ buf->used -= count;
+ buf->start += count;
+ if (buf->start >= buf->len)
+ buf->start -= buf->len;
+}
+
+/*
+ * Commit the data written at the end postion
+ */
+void
+abuf_wcommit(struct abuf *buf, unsigned count)
+{
+ buf->used += count;
+}
+
+/*
* Get a pointer to the writable block at offset ofs.
*/
unsigned char *