From 933c5bf4e21bccb42d178af8d62b73364e301294 Mon Sep 17 00:00:00 2001 From: Martin Budden Date: Mon, 3 Oct 2016 22:33:52 +0100 Subject: [PATCH] Made streambuf const correct --- src/main/common/streambuf.c | 9 +++++++-- src/main/common/streambuf.h | 5 +++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/common/streambuf.c b/src/main/common/streambuf.c index 0f47511e0..118b205b6 100644 --- a/src/main/common/streambuf.c +++ b/src/main/common/streambuf.c @@ -73,14 +73,14 @@ uint32_t sbufReadU32(sbuf_t *src) return ret; } -void sbufReadData(sbuf_t *src, void *data, int len) +void sbufReadData(const sbuf_t *src, void *data, int len) { memcpy(data, src->ptr, len); } // reader - return bytes remaining in buffer // writer - return available space -int sbufBytesRemaining(sbuf_t *buf) +int sbufBytesRemaining(const sbuf_t *buf) { return buf->end - buf->ptr; } @@ -90,6 +90,11 @@ uint8_t* sbufPtr(sbuf_t *buf) return buf->ptr; } +const uint8_t* sbufConstPtr(const sbuf_t *buf) +{ + return buf->ptr; +} + // advance buffer pointer // reader - skip data // writer - commit written data diff --git a/src/main/common/streambuf.h b/src/main/common/streambuf.h index 7de771ef0..0ec169666 100644 --- a/src/main/common/streambuf.h +++ b/src/main/common/streambuf.h @@ -36,10 +36,11 @@ void sbufWriteString(sbuf_t *dst, const char *string); uint8_t sbufReadU8(sbuf_t *src); uint16_t sbufReadU16(sbuf_t *src); uint32_t sbufReadU32(sbuf_t *src); -void sbufReadData(sbuf_t *dst, void *data, int len); +void sbufReadData(const sbuf_t *dst, void *data, int len); -int sbufBytesRemaining(sbuf_t *buf); +int sbufBytesRemaining(const sbuf_t *buf); uint8_t* sbufPtr(sbuf_t *buf); +const uint8_t* sbufConstPtr(const sbuf_t *buf); void sbufAdvance(sbuf_t *buf, int size); void sbufSwitchToReader(sbuf_t *buf, uint8_t * base);