diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-08-15 14:25:22 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-08-15 14:25:22 +0100 |
commit | a0642b4897ef4b9d7c9b9f98faaedeee4b41177e (patch) | |
tree | 3c161329a2489f123748f6759ff0ea59b7a4d203 /src/libutil/str_util.h | |
parent | 79fe034e7cdbb09630e2bd5259421f5114fa4b81 (diff) | |
download | rspamd-a0642b4897ef4b9d7c9b9f98faaedeee4b41177e.tar.gz rspamd-a0642b4897ef4b9d7c9b9f98faaedeee4b41177e.zip |
[Minor] Add rspamd_string_len_split utility
Diffstat (limited to 'src/libutil/str_util.h')
-rw-r--r-- | src/libutil/str_util.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/libutil/str_util.h b/src/libutil/str_util.h index b255c125b..02e0ade45 100644 --- a/src/libutil/str_util.h +++ b/src/libutil/str_util.h @@ -533,6 +533,20 @@ gsize rspamd_gstring_strip (GString *s, const gchar *strip_chars); const gchar *rspamd_string_len_strip (const gchar *in, gsize *len, const gchar *strip_chars); +/** + * Returns a NULL terminated list of zero terminated strings based on splitting of + * the base string into parts. If pool is not NULL then memory is allocated from + * the pool. Otherwise, it is allocated from the heap using `g_malloc` (so + * g_strfreev could be used to free stuff) + * @param in + * @param len + * @param spill + * @param max_elts + * @return + */ +gchar ** rspamd_string_len_split (const gchar *in, gsize len, + const gchar *spill, gint max_elts, rspamd_mempool_t *pool); + #define IS_ZERO_WIDTH_SPACE(uc) ((uc) == 0x200B || \ (uc) == 0x200C || \ (uc) == 0x200D || \ |