]> source.dussan.org Git - rspamd.git/commitdiff
Add routine to free fstring mapped ftoks.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 7 Oct 2015 12:10:17 +0000 (13:10 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 7 Oct 2015 12:10:17 +0000 (13:10 +0100)
src/libutil/fstring.c
src/libutil/fstring.h

index 232b0021ced9d7a84d5f46c98ca54a33685e9da7..e63912c9a28927b63e9ec2d12021a899a29f9cf6 100644 (file)
@@ -319,3 +319,14 @@ rspamd_ftok_cmp (const rspamd_ftok_t *s1,
 
        return s1->len - s2->len;
 }
+
+void
+rspamd_fstring_mapped_ftok_free (gpointer p)
+{
+       rspamd_ftok_t *tok = p;
+       rspamd_fstring_t *storage;
+
+       storage = (rspamd_fstring_t *) (tok->begin - 2 * sizeof (gsize));
+       rspamd_fstring_free (storage);
+       g_slice_free1 (sizeof (*tok), tok);
+}
\ No newline at end of file
index abb69dcbcab606056730fd07327ebcac4fec0050..5ca74f4576638d2893175fc0607852df0ea32d5e 100644 (file)
@@ -128,4 +128,14 @@ gint rspamd_ftok_casecmp (const rspamd_ftok_t *s1,
 gint rspamd_ftok_cmp (const rspamd_ftok_t *s1,
                const rspamd_ftok_t *s2);
 
+/**
+ * Free fstring_t that is mapped to ftok_t
+ *
+ * | len | allocated | <data> -- fstring_t
+ *                     <begin> -- tok
+ *
+ * tok is expected to be allocated with g_slice_alloc
+ */
+void rspamd_fstring_mapped_ftok_free (gpointer p);
+
 #endif