From: Vsevolod Stakhov Date: Tue, 13 Oct 2015 16:03:04 +0000 (+0100) Subject: Implement function to convert fixed string to C string X-Git-Tag: 1.0.5~12 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=49c0e94f6569fad2c1f8d1eb20eda79ac2e6b6c8;p=rspamd.git Implement function to convert fixed string to C string --- 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; +}