#define BITOP(a,b,op) \
((a)[(gsize)(b)/(8*sizeof *(a))] op (gsize)1<<((gsize)(b)%(8*sizeof *(a))))
-static gsize
+gsize
rspamd_memcspn (const gchar *s, const gchar *e, gsize len)
{
- gsize byteset[32/sizeof(gsize)];
+ gsize byteset[32 / sizeof(gsize)];
const gchar *p = s, *end = s + len;
- memset(byteset, 0, sizeof byteset);
+ memset (byteset, 0, sizeof byteset);
for (; *e && BITOP (byteset, *(guchar *)e, |=); e++);
for (; p < end && !BITOP (byteset, *(guchar *)p, &); p++);
*/
const void *rspamd_memrchr (const void *m, gint c, gsize len);
+/**
+ * Return length of memory segment starting in `s` that contains no chars from `e`
+ * @param s any input
+ * @param e zero terminated string of exceptions
+ * @param len length of `s`
+ * @return segment size
+ */
+gsize rspamd_memcspn (const gchar *s, const gchar *e, gsize len);
+
#endif /* SRC_LIBUTIL_STR_UTIL_H_ */