diff options
author | Richard Braun <rbraun@sceen.net> | 2017-07-25 20:09:54 +0200 |
---|---|---|
committer | Richard Braun <rbraun@sceen.net> | 2017-07-25 20:09:54 +0200 |
commit | 56fd1f5d9aabdbae8e694e9268875268a2811740 (patch) | |
tree | ffd2f1b0cda190c54399aedb02073c3e3e0799d7 | |
parent | 0f214095fecca1a35df76619cb381c6793e0fdcd (diff) |
cbuf: make cbuf_popb accept an untyped pointer
-rw-r--r-- | cbuf.c | 7 | ||||
-rw-r--r-- | cbuf.h | 2 |
2 files changed, 6 insertions, 3 deletions
@@ -115,13 +115,16 @@ cbuf_pushb(struct cbuf *cbuf, uint8_t byte, bool erase) } int -cbuf_popb(struct cbuf *cbuf, uint8_t *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; } @@ -126,7 +126,7 @@ int cbuf_pushb(struct cbuf *cbuf, uint8_t byte, bool erase); * * If the buffer is empty, ERROR_AGAIN is returned. */ -int cbuf_popb(struct cbuf *cbuf, uint8_t *bytep); +int cbuf_popb(struct cbuf *cbuf, void *bytep); /* * Write into a circular buffer at a specific location. |