Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Glasgow Haskell Compiler
Packages
text
Commits
2f90469a
Commit
2f90469a
authored
Aug 30, 2021
by
Bodigrim
Browse files
Add memchr to utils.c
parent
56c718cb
Changes
1
Hide whitespace changes
Inline
Side-by-side
cbits/utils.c
View file @
2f90469a
...
...
@@ -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
);
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment