diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2020-07-24 13:34:10 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2020-07-24 20:33:33 +0100 |
commit | 1a634c3d5103c9deb6f5fe1c236b5719995f8d11 (patch) | |
tree | fa2b665bc2bc8a88880d3c00c516d4645a5f5cff /src/libutil | |
parent | 9dbae7439d0c01c29566fc0df2cf59c5e5e1aed7 (diff) | |
download | rspamd-1a634c3d5103c9deb6f5fe1c236b5719995f8d11.tar.gz rspamd-1a634c3d5103c9deb6f5fe1c236b5719995f8d11.zip |
[Project] Detect memrchr in systems that supports it
Diffstat (limited to 'src/libutil')
-rw-r--r-- | src/libutil/str_util.c | 9 | ||||
-rw-r--r-- | src/libutil/str_util.h | 6 |
2 files changed, 10 insertions, 5 deletions
diff --git a/src/libutil/str_util.c b/src/libutil/str_util.c index c503396a2..88f757659 100644 --- a/src/libutil/str_util.c +++ b/src/libutil/str_util.c @@ -2898,20 +2898,21 @@ rspamd_ucl_emit_fstring_comments (const ucl_object_t *obj, ucl_object_emit_full (obj, emit_type, &func, comments); } -const void * +#ifndef HAVE_MEMRCHR +void * rspamd_memrchr (const void *m, gint c, gsize len) { const guint8 *p = m; - gsize i; - for (i = len; i > 0; i --) { + for (gsize i = len; i > 0; i --) { if (p[i - 1] == c) { - return p + i - 1; + return (void *)(p + i - 1); } } return NULL; } +#endif struct UConverter * rspamd_get_utf8_converter (void) diff --git a/src/libutil/str_util.h b/src/libutil/str_util.h index f6c2a1389..bc7b4f4b5 100644 --- a/src/libutil/str_util.h +++ b/src/libutil/str_util.h @@ -429,7 +429,11 @@ extern const guchar lc_map[256]; * @param len * @return pointer to the last occurrence or NULL */ -const void *rspamd_memrchr (const void *m, gint c, gsize len); +#ifdef HAVE_MEMRCHR +#define rspamd_memrchr memrchr +#else +void *rspamd_memrchr (const void *m, gint c, gsize len); +#endif /** * Return length of memory segment starting in `s` that contains no chars from `e` |