diff options
Diffstat (limited to 'src/libutil/fstring.c')
-rw-r--r-- | src/libutil/fstring.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/libutil/fstring.c b/src/libutil/fstring.c index e63912c9a..32fabcea4 100644 --- a/src/libutil/fstring.c +++ b/src/libutil/fstring.c @@ -144,6 +144,22 @@ rspamd_fstring_append (rspamd_fstring_t *str, const char *in, gsize len) return str; } +rspamd_fstring_t * +rspamd_fstring_append_chars (rspamd_fstring_t *str, + char c, gsize len) +{ + gsize avail = fstravail (str); + + if (avail < len) { + str = rspamd_fstring_grow (str, len); + } + + memset (str->str + str->len, c, len); + str->len += len; + + return str; +} + void rspamd_fstring_erase (rspamd_fstring_t *str, gsize pos, gsize len) { @@ -329,4 +345,16 @@ rspamd_fstring_mapped_ftok_free (gpointer p) storage = (rspamd_fstring_t *) (tok->begin - 2 * sizeof (gsize)); rspamd_fstring_free (storage); g_slice_free1 (sizeof (*tok), tok); +} + +rspamd_ftok_t * +rspamd_ftok_map (const rspamd_fstring_t *s) +{ + rspamd_ftok_t *tok; + + g_assert (s != NULL); + + tok = g_slice_alloc (sizeof (*tok)); + tok->begin = s->str; + tok->len = s->len; }
\ No newline at end of file |