summaryrefslogtreecommitdiff
path: root/src/lib/memmove.c
blob: 45528abaa364dd897c106d979f8c37b6d994ea50 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/* SPDX-License-Identifier: GPL-2.0-only */

#include <string.h>
void *memmove(void *vdest, const void *vsrc, size_t count)
{
	const char *src = vsrc;
	char *dest = vdest;

	if (dest <= src) {
		while (count--)
			*dest++ = *src++;
	} else {
		src  += count - 1;
		dest += count - 1;
		while (count--)
			*dest-- = *src--;
	}
	return vdest;
}