diff options
author | dzwdz | 2022-05-15 15:00:35 +0200 |
---|---|---|
committer | dzwdz | 2022-05-15 15:00:35 +0200 |
commit | 27d8fa24b875f2bbcc73dad0795519ef2f5e9cd7 (patch) | |
tree | 33774779c4b43c446808ca2052a63ac30aef10bc /src/shared | |
parent | b35813737665afbbab0c226a2e6b1cb7406d4d40 (diff) |
shared/ring: use char* for the buffer
i don't think uint8_t can alias. char can
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/container/ring.c | 4 | ||||
-rw-r--r-- | src/shared/container/ring.h | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/src/shared/container/ring.c b/src/shared/container/ring.c index 8c56acd..5073b4a 100644 --- a/src/shared/container/ring.c +++ b/src/shared/container/ring.c @@ -21,14 +21,14 @@ void ring_put(ring_t *r, void *buf, size_t len) { void ring_put1b(ring_t *r, uint8_t byte) { if (at_end(r)) return; - ((uint8_t*)r->buf)[r->_head++] = byte; + r->buf[r->_head++] = byte; if (r->_head >= r->capacity) r->_head = 0; } size_t ring_get(ring_t *r, void *buf, size_t len) { for (size_t i = 0; i < len; i++) { if (r->_head == r->_tail || at_end(r)) return i; - ((uint8_t*)buf)[i] = ((uint8_t*)r->buf)[r->_tail++]; + ((uint8_t*)buf)[i] = r->buf[r->_tail++]; if (r->_tail >= r->capacity) r->_tail = 0; } return len; diff --git a/src/shared/container/ring.h b/src/shared/container/ring.h index 434f6aa..219f4fb 100644 --- a/src/shared/container/ring.h +++ b/src/shared/container/ring.h @@ -3,7 +3,7 @@ #include <stdint.h> typedef struct { - void *buf; + char *buf; size_t capacity; size_t _head, _tail; } ring_t; |