summaryrefslogtreecommitdiff
path: root/kern/cbuf.c
diff options
context:
space:
mode:
Diffstat (limited to 'kern/cbuf.c')
-rw-r--r--kern/cbuf.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/kern/cbuf.c b/kern/cbuf.c
index 95dd20fc..2093f428 100644
--- a/kern/cbuf.c
+++ b/kern/cbuf.c
@@ -17,6 +17,7 @@
#include <assert.h>
#include <stddef.h>
+#include <stdint.h>
#include <string.h>
#include <kern/cbuf.h>
@@ -27,7 +28,7 @@
#define CBUF_INIT_INDEX ((size_t)-500)
void
-cbuf_init(struct cbuf *cbuf, char *buf, size_t capacity)
+cbuf_init(struct cbuf *cbuf, void *buf, size_t capacity)
{
assert(ISP2(capacity));
@@ -84,7 +85,7 @@ cbuf_pop(struct cbuf *cbuf, void *buf, size_t *sizep)
}
int
-cbuf_pushb(struct cbuf *cbuf, char byte, bool erase)
+cbuf_pushb(struct cbuf *cbuf, uint8_t byte, bool erase)
{
size_t free_size;
@@ -103,13 +104,16 @@ cbuf_pushb(struct cbuf *cbuf, char byte, bool erase)
}
int
-cbuf_popb(struct cbuf *cbuf, char *bytep)
+cbuf_popb(struct cbuf *cbuf, void *bytep)
{
+ uint8_t *ptr;
+
if (cbuf_size(cbuf) == 0) {
return ERROR_AGAIN;
}
- *bytep = cbuf->buf[cbuf_index(cbuf, cbuf->start)];
+ ptr = bytep;
+ *ptr = cbuf->buf[cbuf_index(cbuf, cbuf->start)];
cbuf->start++;
return 0;
}
@@ -117,7 +121,7 @@ cbuf_popb(struct cbuf *cbuf, char *bytep)
int
cbuf_write(struct cbuf *cbuf, size_t index, const void *buf, size_t size)
{
- char *start, *end, *buf_end;
+ uint8_t *start, *end, *buf_end;
size_t new_end, skip;
if (!cbuf_range_valid(cbuf, index, cbuf->end)) {
@@ -157,7 +161,7 @@ cbuf_write(struct cbuf *cbuf, size_t index, const void *buf, size_t size)
int
cbuf_read(const struct cbuf *cbuf, size_t index, void *buf, size_t *sizep)
{
- const char *start, *end, *buf_end;
+ const uint8_t *start, *end, *buf_end;
size_t size;
/* At least one byte must be available */