blob: 17ee0c4be06d64baffc0fb7087bfdae7bdae99ba (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
#include <string.h>
#include "_safety.h"
void *memccpy(void * restrict s1, const void * restrict s2, int c, size_t n)
{
SIGNAL_SAFE(0);
unsigned char *dst = s1;
const unsigned char *src = s2;
size_t i = 0;
ASSERT_NOOVERLAP(s1, s2, n);
for (i = 0; i < n; i++) {
dst[i] = src[i];
if (dst[i] == (unsigned char)c) {
return dst + i + 1;
}
}
return NULL;
}
/*
XOPEN(4)
*/
|