cub3d/libft/src/ft_memcmp.c

36 lines
1.2 KiB
C
Raw Normal View History

2023-10-25 13:56:45 +02:00
/* ************************************************************************** */
/* */
/* :::::::: */
2023-10-26 19:11:30 +02:00
/* ft_memcmp.c :+: :+: */
2023-10-25 13:56:45 +02:00
/* +:+ */
/* By: djonker <marvin@codam.nl> +#+ */
/* +#+ */
/* Created: 2020/11/01 08:41:32 by djonker #+# #+# */
2023-10-26 19:11:30 +02:00
/* Updated: 2023/10/18 16:59:58 by houtworm ######## odam.nl */
2023-10-25 13:56:45 +02:00
/* */
/* ************************************************************************** */
#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);
}