common/strbuf.c: attach function.
This commit is contained in:
parent
3abbb2b63e
commit
9fbe9cfc23
2 changed files with 12 additions and 0 deletions
|
|
@ -72,6 +72,16 @@ void strbuf_free(strbuf_t *s) {
|
||||||
strbuf_init(s);
|
strbuf_init(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void strbuf_attach(strbuf_t *s, void *buf, size_t len, size_t alloc_size) {
|
||||||
|
|
||||||
|
strbuf_free(s);
|
||||||
|
s->buf = buf;
|
||||||
|
s->len = len;
|
||||||
|
s->alloc_size = alloc_size;
|
||||||
|
strbuf_expand(s, 0);
|
||||||
|
s->buf[s->len] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
void strbuf_append(strbuf_t *s, const void *ptr, size_t len) {
|
void strbuf_append(strbuf_t *s, const void *ptr, size_t len) {
|
||||||
|
|
||||||
strbuf_expand(s, len);
|
strbuf_expand(s, len);
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,8 @@ char* strbuf_release(strbuf_t *s);
|
||||||
|
|
||||||
void strbuf_free(strbuf_t *s);
|
void strbuf_free(strbuf_t *s);
|
||||||
|
|
||||||
|
void strbuf_attach(strbuf_t *s, void *str, size_t len, size_t alloc_size);
|
||||||
|
|
||||||
void strbuf_append(strbuf_t *s, const void *ptr, size_t len);
|
void strbuf_append(strbuf_t *s, const void *ptr, size_t len);
|
||||||
|
|
||||||
void strbuf_append_str(strbuf_t *s, const char *str);
|
void strbuf_append_str(strbuf_t *s, const char *str);
|
||||||
|
|
|
||||||
Reference in a new issue