summaryrefslogtreecommitdiffstats
path: root/mdk-stage1/dietlibc/lib/memrchr.c
blob: f7750d2d7899ba10344f319524c74f4d2ece40c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#define _GNU_SOURCE
#include <sys/types.h>
#include <string.h>

void* memrchr(const void *s, int c, size_t n) {
  register const char* t=s;
  register const char* last=0;
  int i;
  for (i=n; i; --i) {
    if (*t==c)
      last=t;
    ++t;
  }
  return (void*)last; /* man, what an utterly b0rken prototype */
}