aboutsummaryrefslogtreecommitdiffstats
path: root/memory/memrchr.c
diff options
context:
space:
mode:
Diffstat (limited to 'memory/memrchr.c')
-rw-r--r--memory/memrchr.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/memory/memrchr.c b/memory/memrchr.c
new file mode 100644
index 0000000..6413808
--- /dev/null
+++ b/memory/memrchr.c
@@ -0,0 +1,10 @@
+#include "memory.h"
+
+void *memrchr(void const *buf, int value, size_t size)
+{
+ unsigned char const *buffer = buf;
+ for (size_t i = size; i-- > 0;)
+ if (buffer[i] == (unsigned char)value)
+ return (void *)&buffer[i];
+ return NULL;
+}