From 49c0e94f6569fad2c1f8d1eb20eda79ac2e6b6c8 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Tue, 13 Oct 2015 17:03:04 +0100 Subject: [PATCH] Implement function to convert fixed string to C string --- src/libutil/fstring.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/libutil/fstring.c b/src/libutil/fstring.c index e6ce5a052..3d5c59061 100644 --- a/src/libutil/fstring.c +++ b/src/libutil/fstring.c @@ -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; +} -- 2.39.5