mirror of
https://github.com/systemd/systemd
synced 2024-09-30 05:15:19 +00:00
strbuf: use _cleanup_ attribute at one more place
This commit is contained in:
parent
c616e30e9c
commit
6548aef1cd
|
@ -27,24 +27,22 @@
|
|||
*/
|
||||
|
||||
struct strbuf* strbuf_new(void) {
|
||||
struct strbuf *str;
|
||||
_cleanup_(strbuf_freep) struct strbuf *str = NULL;
|
||||
|
||||
str = new(struct strbuf, 1);
|
||||
if (!str)
|
||||
return NULL;
|
||||
|
||||
*str = (struct strbuf) {
|
||||
.buf = new0(char, 1),
|
||||
.root = new0(struct strbuf_node, 1),
|
||||
.len = 1,
|
||||
.nodes_count = 1,
|
||||
};
|
||||
if (!str->buf || !str->root) {
|
||||
free(str->buf);
|
||||
free(str->root);
|
||||
return mfree(str);
|
||||
}
|
||||
if (!str->buf || !str->root)
|
||||
return NULL;
|
||||
|
||||
return str;
|
||||
return TAKE_PTR(str);
|
||||
}
|
||||
|
||||
static struct strbuf_node* strbuf_node_cleanup(struct strbuf_node *node) {
|
||||
|
|
Loading…
Reference in a new issue