From: Vsevolod Stakhov Date: Wed, 7 Oct 2015 12:10:17 +0000 (+0100) Subject: Add routine to free fstring mapped ftoks. X-Git-Tag: 1.0.5~66^2~17 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=62b2188d8282e5dda9a388a851cd701434f69124;p=rspamd.git Add routine to free fstring mapped ftoks. --- diff --git a/src/libutil/fstring.c b/src/libutil/fstring.c index 232b0021c..e63912c9a 100644 --- a/src/libutil/fstring.c +++ b/src/libutil/fstring.c @@ -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 diff --git a/src/libutil/fstring.h b/src/libutil/fstring.h index abb69dcbc..5ca74f457 100644 --- a/src/libutil/fstring.h +++ b/src/libutil/fstring.h @@ -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 | -- fstring_t + * -- tok + * + * tok is expected to be allocated with g_slice_alloc + */ +void rspamd_fstring_mapped_ftok_free (gpointer p); + #endif