Browse Source

Made streambuf const correct

master
Martin Budden 8 years ago
committed by Konstantin Sharlaimov
parent
commit
933c5bf4e2
  1. 9
      src/main/common/streambuf.c
  2. 5
      src/main/common/streambuf.h

9
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

5
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);
Loading…
Cancel
Save