summaryrefslogtreecommitdiff
path: root/src/basic
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2021-02-16 13:48:04 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2021-02-16 17:15:10 +0100
commit75db809ae583ef7287e39738195c0825c3070843 (patch)
tree9793b944d340516003c0fc10ccb9322a4e126721 /src/basic
parent5d160a23041254f58acfd35584103df57dc347ae (diff)
downloadsystemd-75db809ae583ef7287e39738195c0825c3070843.tar.gz
tree-wide: return NULL from freeing functions
I started working on this because I wanted to change how DEFINE_TRIVIAL_CLEANUP_FUNC is defined. Even independently of that change, it's nice to make make things more consistent and predictable.
Diffstat (limited to 'src/basic')
-rw-r--r--src/basic/strbuf.c8
-rw-r--r--src/basic/strbuf.h4
2 files changed, 6 insertions, 6 deletions
diff --git a/src/basic/strbuf.c b/src/basic/strbuf.c
index aee6647e35..535ac58bed 100644
--- a/src/basic/strbuf.c
+++ b/src/basic/strbuf.c
@@ -26,7 +26,7 @@
* ...
*/
-struct strbuf *strbuf_new(void) {
+struct strbuf* strbuf_new(void) {
struct strbuf *str;
str = new(struct strbuf, 1);
@@ -65,13 +65,13 @@ void strbuf_complete(struct strbuf *str) {
}
/* clean up everything */
-void strbuf_cleanup(struct strbuf *str) {
+struct strbuf* strbuf_cleanup(struct strbuf *str) {
if (!str)
- return;
+ return NULL;
strbuf_complete(str);
free(str->buf);
- free(str);
+ return mfree(str);
}
static int strbuf_children_cmp(const struct strbuf_child_entry *n1,
diff --git a/src/basic/strbuf.h b/src/basic/strbuf.h
index 82758d721b..9a21438d64 100644
--- a/src/basic/strbuf.h
+++ b/src/basic/strbuf.h
@@ -32,8 +32,8 @@ struct strbuf_child_entry {
struct strbuf_node *child;
};
-struct strbuf *strbuf_new(void);
+struct strbuf* strbuf_new(void);
ssize_t strbuf_add_string(struct strbuf *str, const char *s, size_t len);
void strbuf_complete(struct strbuf *str);
-void strbuf_cleanup(struct strbuf *str);
+struct strbuf* strbuf_cleanup(struct strbuf *str);
DEFINE_TRIVIAL_CLEANUP_FUNC(struct strbuf*, strbuf_cleanup);