]> source.dussan.org Git - rspamd.git/commitdiff
Implement function to convert fixed string to C string
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 13 Oct 2015 16:03:04 +0000 (17:03 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 13 Oct 2015 16:03:04 +0000 (17:03 +0100)
src/libutil/fstring.c

index e6ce5a052b8176135b0c16233af2305bae93e288..3d5c59061ac8b51d24405b0d41f8081565fc83b9 100644 (file)
@@ -360,3 +360,19 @@ rspamd_ftok_map (const rspamd_fstring_t *s)
 
        return tok;
 }
+
+char *
+rspamd_fstring_cstr (const rspamd_fstring_t *s)
+{
+       char *result;
+
+       if (s == NULL) {
+               return NULL;
+       }
+
+       result = g_malloc (s->len + 1);
+       memcpy (result, s->str, s->len);
+       result[s->len] = '\0';
+
+       return result;
+}