diff options
author | Iru Cai <mytbk920423@gmail.com> | 2018-05-21 14:32:34 +0800 |
---|---|---|
committer | Iru Cai <mytbk920423@gmail.com> | 2018-05-21 16:45:38 +0800 |
commit | b44293b115bbe69033ab9c066d301e1f7aaf64cf (patch) | |
tree | 51a8f7474b5621b25b459513b1444e96dd279242 /src/protocol/internal/buffer.h | |
parent | 9f00a9265c05dc02ad1b1e4c8148e1950c394530 (diff) | |
download | fqterm-b44293b115bbe69033ab9c066d301e1f7aaf64cf.tar.xz |
buffer_append: support NULL argument s to just allocate the space
Diffstat (limited to 'src/protocol/internal/buffer.h')
-rw-r--r-- | src/protocol/internal/buffer.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/protocol/internal/buffer.h b/src/protocol/internal/buffer.h index 0e0b635..0cfdca6 100644 --- a/src/protocol/internal/buffer.h +++ b/src/protocol/internal/buffer.h @@ -44,6 +44,9 @@ static inline void buffer_clear(buffer *b) { b->offs = b->sz = 0; } static inline void buffer_deinit(buffer *b) { free(b->p); } static inline uint8_t *buffer_data(buffer *b) { return b->p + b->offs; } static inline size_t buffer_len(buffer *b) { return b->sz; } +/* buffer_append: append data in s to buffer b, + * if s is NULL, then just allocate len bytes of space in b + */ int buffer_append(buffer *b, const uint8_t *s, size_t len); int buffer_append_string(buffer *b, const char *s, size_t len); int buffer_append_byte(buffer *b, uint8_t); |