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.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2021-02-16 17:15:10 +01:00
parent 5d160a2304
commit 75db809ae5
52 changed files with 154 additions and 165 deletions
+4 -4
View File
@@ -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,
+2 -2
View File
@@ -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);