From e8a7e1c358caec60751460d337f634ff6957ff9d Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Mon, 19 Nov 2018 21:39:11 +0100 Subject: Add a bunch of function and macros MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- memrchr_inv.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 memrchr_inv.c (limited to 'memrchr_inv.c') diff --git a/memrchr_inv.c b/memrchr_inv.c new file mode 100644 index 0000000..d7239b3 --- /dev/null +++ b/memrchr_inv.c @@ -0,0 +1,25 @@ +/* See LICENSE file for copyright and license details. */ +#include "libsimple.h" +#ifndef TEST + + +void * +libsimple_memrchr_inv(const void *s_, int c_, size_t n_) /* TODO test, man */ +{ + char *s = *(char **)(void *)&s_, c = (char)c_; + ssize_t n = n_; + while (n-- && s[n] == c); + return n < 0 ? NULL : &s[n]; +} + + +#else +#include "test.h" + +int +main(void) +{ + return 0; +} + +#endif -- cgit v1.2.3-70-g09d2