diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-10-06 15:41:16 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-10-06 15:41:16 +0100 |
commit | aac916db77b6ae58b7c0186d764e97a25482017c (patch) | |
tree | 52d58a063d790c699913116ee790b2a3019a6615 /src/libutil/fstring.c | |
parent | c7f92da47dcb17393132b713f75a4dbd41629819 (diff) | |
download | rspamd-aac916db77b6ae58b7c0186d764e97a25482017c.tar.gz rspamd-aac916db77b6ae58b7c0186d764e97a25482017c.zip |
Start miration to the new strings.
Diffstat (limited to 'src/libutil/fstring.c')
-rw-r--r-- | src/libutil/fstring.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/libutil/fstring.c b/src/libutil/fstring.c index 9e96aac3c..ba580cd8b 100644 --- a/src/libutil/fstring.c +++ b/src/libutil/fstring.c @@ -48,7 +48,7 @@ rspamd_fstring_t * rspamd_fstring_sized_new (gsize initial_size) { rspamd_fstring_t *s; - gsize real_size = MAX(default_initial_size, initial_size); + gsize real_size = MAX (default_initial_size, initial_size); g_assert (posix_memalign ((void **)&s, 16, real_size + sizeof (*s)) == 0); s->len = 0; @@ -57,6 +57,20 @@ rspamd_fstring_sized_new (gsize initial_size) return s; } +rspamd_fstring_t * +rspamd_fstring_new_init (const gchar *init, gsize len) +{ + rspamd_fstring_t *s; + gsize real_size = MAX (default_initial_size, len); + + g_assert (posix_memalign ((void **) &s, 16, real_size + sizeof (*s)) == 0); + s->len = len; + s->allocated = real_size; + memcpy (s->str, init, len); + + return s; +} + void rspamd_fstring_free (rspamd_fstring_t *str) { |