Refactor: moves memrchr to global impl for potential future use

This commit is contained in:
李通洲
2026-02-10 18:16:58 +08:00
parent 61cdfcabf8
commit 996cdd3155
6 changed files with 42 additions and 26 deletions
+19
View File
@@ -0,0 +1,19 @@
#include "common/memrchr.h"
#include <stddef.h>
#include <stdint.h>
void* memrchr(const void* s, int c, size_t n)
{
if (n == 0) return NULL;
const uint8_t uc = (uint8_t) c;
const uint8_t* p = (const uint8_t*) s + n;
while (n--)
{
if (*--p == uc) return (void*) p;
}
return NULL;
}