mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:42:09 +02:00
22 lines
364 B
C
22 lines
364 B
C
#include "common/memrchr.h"
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
|
|
void* memrchr(const void* s, int c, size_t n) {
|
|
if (n == 0) {
|
|
return nullptr;
|
|
}
|
|
|
|
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 nullptr;
|
|
}
|