mirror of
https://github.com/ruby/ruby.git
synced 2026-08-01 02:20:48 +08:00
Move the local fallback out of string.c so other source files can use memrchr on platforms that do not provide it.
13 lines
272 B
C
13 lines
272 B
C
#include "ruby/missing.h"
|
|
|
|
void *
|
|
memrchr(const void *ptr, int ch, size_t len)
|
|
{
|
|
const unsigned char *p = (const unsigned char *)ptr + len;
|
|
|
|
while (p > (const unsigned char *)ptr) {
|
|
if (*--p == (unsigned char)ch) return (void *)p;
|
|
}
|
|
return NULL;
|
|
}
|