1
0

wip_parsing

This commit is contained in:
Maelys
2024-09-10 16:27:06 +02:00
commit c671539661
62 changed files with 1863 additions and 0 deletions

19
libft/mem/ft_bzero.c Normal file
View File

@ -0,0 +1,19 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_bzero.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: madumerg <madumerg@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/10/30 17:15:50 by madumerg #+# #+# */
/* Updated: 2023/11/02 13:48:10 by madumerg ### ########.fr */
/* */
/* ************************************************************************** */
#include <stddef.h>
#include "libft.h"
void ft_bzero(void *s, size_t count)
{
ft_memset(s, 0, count);
}

30
libft/mem/ft_calloc.c Normal file
View File

@ -0,0 +1,30 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_calloc.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: madumerg <madumerg@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/10/31 14:41:05 by madumerg #+# #+# */
/* Updated: 2023/11/09 16:18:08 by madumerg ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_calloc(size_t ct, size_t size)
{
char *str;
if (size == 0 || ct == 0)
return (malloc(1));
if ((int)size < 0 && (int)ct < 0)
return (NULL);
if ((unsigned long long)(size * ct) > UINT_MAX)
return (NULL);
str = malloc(size * ct);
if (!str)
return (NULL);
ft_bzero(str, size * ct);
return (str);
}

29
libft/mem/ft_memchr.c Normal file
View File

@ -0,0 +1,29 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: madumerg <madumerg@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/10/31 14:41:18 by madumerg #+# #+# */
/* Updated: 2023/11/09 16:24:27 by madumerg ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memchr(const void *s, int c, size_t n)
{
size_t i;
i = 0;
if (!s)
return (0);
while (i < n)
{
if (*(unsigned char *)(s + i) == (unsigned char)c)
return ((void *)(s + i));
i++;
}
return (0);
}

31
libft/mem/ft_memcmp.c Normal file
View File

@ -0,0 +1,31 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: madumerg <madumerg@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/10/31 14:42:37 by madumerg #+# #+# */
/* Updated: 2023/11/02 14:11:43 by madumerg ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_memcmp(const void *s1, const void *s2, size_t n)
{
size_t i;
unsigned char *ptr1;
unsigned char *ptr2;
ptr1 = (unsigned char *) s1;
ptr2 = (unsigned char *) s2;
i = 0;
while (i < n)
{
if (ptr1[i] != ptr2[i])
return (ptr1[i] - ptr2[i]);
i++;
}
return (0);
}

28
libft/mem/ft_memcpy.c Normal file
View File

@ -0,0 +1,28 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: madumerg <madumerg@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/10/31 14:42:45 by madumerg #+# #+# */
/* Updated: 2023/11/09 16:21:18 by madumerg ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memcpy(void *dest, const void *src, size_t n)
{
size_t i;
i = 0;
if (!dest)
return (NULL);
while (i != n)
{
*(unsigned char *)(dest + i) = *(unsigned char *)(src + i);
i++;
}
return (dest);
}

40
libft/mem/ft_memmove.c Normal file
View File

@ -0,0 +1,40 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memmove.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: madumerg <madumerg@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/10/31 14:41:28 by madumerg #+# #+# */
/* Updated: 2023/11/09 16:24:06 by madumerg ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memmove(void *dest, const void *src, size_t size)
{
size_t i;
i = 0;
if (!dest && !src)
return (NULL);
if (dest > src)
{
i = size;
while (i > 0)
{
i--;
*(unsigned char *)(dest + i) = *(unsigned char *)(src + i);
}
}
else
{
while (i != size)
{
*(unsigned char *)(dest + i) = *(unsigned char *)(src + i);
i++;
}
}
return (dest);
}

26
libft/mem/ft_memset.c Normal file
View File

@ -0,0 +1,26 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memset.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: madumerg <madumerg@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/10/31 14:42:15 by madumerg #+# #+# */
/* Updated: 2023/11/02 14:11:59 by madumerg ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memset(void *ptr, int v, size_t count)
{
size_t i;
i = 0;
while (i != count)
{
*(unsigned char *)(ptr + i) = (unsigned char)v;
i++;
}
return (ptr);
}