]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Minor] Add helper to free GError for memopry pool management
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 12 Feb 2018 15:39:47 +0000 (15:39 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 12 Feb 2018 15:57:33 +0000 (15:57 +0000)
src/libutil/util.c
src/libutil/util.h

index 035369e6738e693a4af7103e32b044ab880feae7..0002c84dee30b8cfcc5c1bf43c9e7c8a5cf18585 100644 (file)
@@ -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 *
index a1b4f95bb2a5c60d139c8a84c9a1e33700370473..adb645600f0f3a0acd0a4916a88c5d4f089b3f42 100644 (file)
@@ -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