aboutsummaryrefslogblamecommitdiffstats
path: root/memrchr.c
blob: 6beec6d6d0d21889eb68caa71331f9c8434b3d15 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12











                                                         
/* See LICENSE file for copyright and license details. */
#include "libsimple.h"


void *
libsimple_memrchr(const void *s_, int c, size_t n_)
{
	char *s = *(char **)(void *)&s_;
	ssize_t n = n_;
	while (n-- && (int)s[n] != c);
	return n < 0 ? NULL : &s[n];
}