Commit 2f90469a authored by Bodigrim's avatar Bodigrim
Browse files

Add memchr to utils.c

parent 56c718cb
......@@ -2,10 +2,18 @@
* Copyright (c) 2021 Andrew Lelechenko <andrew.lelechenko@gmail.com>
*/
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
int _hs_text_memcmp(const void *arr1, size_t off1, const void *arr2, size_t off2, size_t len)
{
return memcmp(arr1 + off1, arr2 + off2, len);
}
ssize_t _hs_text_memchr(const void *arr, size_t off, size_t len, uint8_t byte)
{
const void *ptr = memchr(arr + off, byte, len);
return ptr == NULL ? -1 : ptr - (arr + off);
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment