From 424bf837f936bb2d02c06c839d08139a871f36d6 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Thu, 21 Jun 2018 14:20:13 +0100 Subject: [Minor] Add rspamd_memspn function --- src/libutil/str_util.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/libutil/str_util.h') diff --git a/src/libutil/str_util.h b/src/libutil/str_util.h index 45507e2be..9fa914292 100644 --- a/src/libutil/str_util.h +++ b/src/libutil/str_util.h @@ -334,6 +334,14 @@ const void *rspamd_memrchr (const void *m, gint c, gsize len); */ gsize rspamd_memcspn (const gchar *s, const gchar *e, gsize len); +/** + * Return length of memory segment starting in `s` that contains only chars from `e` + * @param s any input + * @param e zero terminated string of inclusions + * @param len length of `s` + * @return segment size + */ +gsize rspamd_memspn (const gchar *s, const gchar *e, gsize len); /* https://graphics.stanford.edu/~seander/bithacks.html#HasMoreInWord */ #define rspamd_str_hasmore(x,n) ((((x)+~0UL/255*(127-(n)))|(x))&~0UL/255*128) -- cgit v1.2.3