cub3d/libft/src/ft_memcmp.c
2023-10-26 19:11:30 +02:00

36 lines
1.2 KiB
C

/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_memcmp.c :+: :+: */
/* +:+ */
/* By: djonker <marvin@codam.nl> +#+ */
/* +#+ */
/* Created: 2020/11/01 08:41:32 by djonker #+# #+# */
/* Updated: 2023/10/18 16:59:58 by houtworm ######## odam.nl */
/* */
/* ************************************************************************** */
#include "../libft.h"
int ft_memcmp(const void *s1, const void *s2, size_t n)
{
const unsigned char *p1;
const unsigned char *p2;
if (!s1 && !s2)
return (0);
if (!s1 || !s2)
return (1);
p1 = s1;
p2 = s2;
while (n)
{
if (*p1 != *p2)
return (*p1 - *p2);
p1++;
p2++;
n--;
}
return (0);
}