diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-05-09 15:45:43 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-05-09 15:45:43 +0100 |
commit | 4ef507e1592efbe33ca948f6bc76e4f100921184 (patch) | |
tree | 854ebe02911ddc48a76d54624c7b892ba3ccb2c9 /src/libutil/fstring.c | |
parent | 6a48a0a416a64c30c8ab89b9f468b523f46b1bb9 (diff) | |
download | rspamd-4ef507e1592efbe33ca948f6bc76e4f100921184.tar.gz rspamd-4ef507e1592efbe33ca948f6bc76e4f100921184.zip |
[Feature] Add utility method to convert ftok to C string
Diffstat (limited to 'src/libutil/fstring.c')
-rw-r--r-- | src/libutil/fstring.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/libutil/fstring.c b/src/libutil/fstring.c index 997dd6b46..285940f9c 100644 --- a/src/libutil/fstring.c +++ b/src/libutil/fstring.c @@ -400,3 +400,19 @@ rspamd_ftok_cstr_equal (const rspamd_ftok_t *s, const gchar *pat, return (rspamd_ftok_cmp (s, &srch) == 0); } + +gchar * +rspamd_ftokdup (const rspamd_ftok_t *src) +{ + gchar *newstr; + + if (src == NULL) { + return NULL; + } + + newstr = g_malloc (src->len + 1); + memcpy (newstr, src->begin, src->len); + newstr[src->len] = '\0'; + + return newstr; +} |