From: Vsevolod Stakhov Date: Mon, 12 Feb 2018 15:39:47 +0000 (+0000) Subject: [Minor] Add helper to free GError for memopry pool management X-Git-Tag: 1.7.0~202 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c23f9a17f6b60b3eee4f4cc51bddc6ec11b0092b;p=thirdparty%2Frspamd.git [Minor] Add helper to free GError for memopry pool management --- diff --git a/src/libutil/util.c b/src/libutil/util.c index 035369e673..0002c84dee 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 a1b4f95bb2..adb645600f 100644 --- a/src/libutil/util.h +++ b/src/libutil/util.h @@ -330,6 +330,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