Merge branch 'jk/strbuf-detach-always-non-null'
* jk/strbuf-detach-always-non-null: strbuf: always return a non-NULL value from strbuf_detach
This commit is contained in:
commit
2cfceefaca
4
strbuf.c
4
strbuf.c
@ -44,7 +44,9 @@ void strbuf_release(struct strbuf *sb)
|
|||||||
|
|
||||||
char *strbuf_detach(struct strbuf *sb, size_t *sz)
|
char *strbuf_detach(struct strbuf *sb, size_t *sz)
|
||||||
{
|
{
|
||||||
char *res = sb->alloc ? sb->buf : NULL;
|
char *res;
|
||||||
|
strbuf_grow(sb, 0);
|
||||||
|
res = sb->buf;
|
||||||
if (sz)
|
if (sz)
|
||||||
*sz = sb->len;
|
*sz = sb->len;
|
||||||
strbuf_init(sb, 0);
|
strbuf_init(sb, 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user