aboutsummaryrefslogtreecommitdiffstats
path: root/memory/memccpy.c
blob: b960b34f405cf8ba5cc5d0d33d3567d2ce37f1fa (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include "memory.h"

void *memccpy(void *restrict dest, void const *restrict src, int value,
	      size_t count)
{
	unsigned char *restrict destination = dest;
	unsigned char const *restrict source = src;
	for (size_t i = 0; i < count; i++) {
		destination[i] = source[i];
		if (destination[i] == (unsigned char)value)
			return &destination[i + 1];
	}
	return NULL;
}