diff options
author | Richard Braun <rbraun@sceen.net> | 2017-07-25 19:54:15 +0200 |
---|---|---|
committer | Richard Braun <rbraun@sceen.net> | 2017-07-25 19:54:15 +0200 |
commit | 35a930f32bfbc7e07d2b0ed70a63fb32c27b22a2 (patch) | |
tree | 714b23b1478343f9fb9555afd3c7eb67d3ff7cbf /cbuf.c | |
parent | 61494ce3960eb4b51c1786dd26a3fe6bbeefc35b (diff) |
cbuf: minor improvements
Use the unsigned uint8_t type instead of char. Simplify interface
description.
Diffstat (limited to 'cbuf.c')
-rw-r--r-- | cbuf.c | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -28,6 +28,7 @@ #include <assert.h> #include <stddef.h> +#include <stdint.h> #include <string.h> #include "cbuf.h" @@ -38,7 +39,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)); @@ -95,7 +96,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; @@ -114,7 +115,7 @@ cbuf_pushb(struct cbuf *cbuf, char byte, bool erase) } int -cbuf_popb(struct cbuf *cbuf, char *bytep) +cbuf_popb(struct cbuf *cbuf, uint8_t *bytep) { if (cbuf_size(cbuf) == 0) { return ERR_AGAIN; @@ -128,7 +129,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)) { @@ -168,7 +169,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 */ |