diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-02-12 15:39:47 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-02-12 15:57:33 +0000 |
commit | c23f9a17f6b60b3eee4f4cc51bddc6ec11b0092b (patch) | |
tree | ccabc06b8ac06fdfed682176c84bde13d2629284 /src | |
parent | aa26e139bad1744a36d3878804e22116f90afafb (diff) | |
download | rspamd-c23f9a17f6b60b3eee4f4cc51bddc6ec11b0092b.tar.gz rspamd-c23f9a17f6b60b3eee4f4cc51bddc6ec11b0092b.zip |
[Minor] Add helper to free GError for memopry pool management
Diffstat (limited to 'src')
-rw-r--r-- | src/libutil/util.c | 13 | ||||
-rw-r--r-- | src/libutil/util.h | 6 |
2 files changed, 15 insertions, 4 deletions
diff --git a/src/libutil/util.c b/src/libutil/util.c index 035369e67..0002c84de 100644 --- a/src/libutil/util.c +++ b/src/libutil/util.c @@ -1973,12 +1973,17 @@ rspamd_gstring_free_hard (gpointer p) g_string_free (ar, TRUE); } -void -rspamd_gstring_free_soft (gpointer p) +void rspamd_gerror_free_maybe (gpointer p) { - GString *ar = (GString *)p; + GError **err; + + if (p) { + err = (GError **)p; - g_string_free (ar, FALSE); + if (*err) { + g_error_free (*err); + } + } } struct rspamd_external_libs_ctx * diff --git a/src/libutil/util.h b/src/libutil/util.h index a1b4f95bb..adb645600 100644 --- a/src/libutil/util.h +++ b/src/libutil/util.h @@ -331,6 +331,12 @@ void rspamd_array_free_hard (gpointer p); void rspamd_gstring_free_hard (gpointer p); /** + * Special utility to help GError freeing in rspamd_mempool + * @param p + */ +void rspamd_gerror_free_maybe (gpointer p); + +/** * Special utility to help GString freeing (without freeing the memory segment) in rspamd_mempool * @param p */ |