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

int rawmemccmp(void const *buffer1, void const *buffer2, unsigned char value)
{
	unsigned char const *buffer[] = {buffer1, buffer2};
	for (size_t i = 0;; i++) {
		if (buffer[0][i] != buffer[1][i])
			return (int)buffer[0][i] - (int)buffer[1][i];
		if (buffer[0][i] == (unsigned char)value ||
		    buffer[1][i] == (unsigned char)value)
			return 0;
	}
}