raw write functions now aware about RO buffer flag;
This commit is contained in:
parent
b07795a039
commit
4850357dc4
4
ndbuf.c
4
ndbuf.c
@ -298,6 +298,7 @@ static inline int __ndbuf_is_nrea(ndbuf_t *b)
|
||||
uint32_t ndbuf_write_u8(ndbuf_t *b, uint8_t u)
|
||||
{
|
||||
if(!b || !b->raw) return 0;
|
||||
if(__ndbuf_is_ro(b)) return 0; /* read only buffer */
|
||||
if(b->ulength == b->rlength) {
|
||||
if(__ndbuf_is_nrea(b)) return 0; /* non reallocatable buffer */
|
||||
if(__rdb_grow(b, sizeof(uint8_t))) return 0;
|
||||
@ -312,6 +313,7 @@ uint32_t ndbuf_write_u8(ndbuf_t *b, uint8_t u)
|
||||
uint32_t ndbuf_write_u16(ndbuf_t *b, uint16_t uu)
|
||||
{
|
||||
if(!b || !b->raw) return 0;
|
||||
if(__ndbuf_is_ro(b)) return 0; /* read only buffer */
|
||||
if(b->ulength + sizeof(uint16_t) >= b->rlength) {
|
||||
if(__ndbuf_is_nrea(b)) return 0; /* non reallocatable buffer */
|
||||
if(__rdb_grow(b, sizeof(uint16_t))) return 0;
|
||||
@ -326,6 +328,7 @@ uint32_t ndbuf_write_u16(ndbuf_t *b, uint16_t uu)
|
||||
uint32_t ndbuf_write_u32(ndbuf_t *b, uint32_t uu)
|
||||
{
|
||||
if(!b || !b->raw) return 0;
|
||||
if(__ndbuf_is_ro(b)) return 0; /* read only buffer */
|
||||
if(b->ulength + sizeof(uint32_t) >= b->rlength) {
|
||||
if(__ndbuf_is_nrea(b)) return 0; /* non reallocatable buffer */
|
||||
if(__rdb_grow(b, sizeof(uint32_t))) return 0;
|
||||
@ -340,6 +343,7 @@ uint32_t ndbuf_write_u32(ndbuf_t *b, uint32_t uu)
|
||||
uint32_t ndbuf_write_u64(ndbuf_t *b, uint64_t uu)
|
||||
{
|
||||
if(!b || !b->raw) return 0;
|
||||
if(__ndbuf_is_ro(b)) return 0; /* read only buffer */
|
||||
if(b->ulength + sizeof(uint64_t) >= b->rlength) {
|
||||
if(__ndbuf_is_nrea(b)) return 0; /* non reallocatable buffer */
|
||||
if(__rdb_grow(b, sizeof(uint64_t))) return 0;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user