1
0
mirror of https://github.com/KeyZox71/ft_minipowershell.git synced 2025-06-25 02:13:35 +02:00

」 feat(libft): added a very cool feature !

This commit is contained in:
2024-04-24 10:53:46 +02:00
parent 28128acd72
commit 59b810ffa4
64 changed files with 2063 additions and 0 deletions

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

@ -0,0 +1,18 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_bzero.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/03 11:58:03 by adjoly #+# #+# */
/* Updated: 2024/02/04 13:55:51 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#include "../libft.h"
void ft_bzero(void *s, size_t n)
{
ft_memset(s, '\0', n);
}

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

@ -0,0 +1,36 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_calloc.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/01 16:02:26 by adjoly #+# #+# */
/* Updated: 2024/03/04 10:10:58 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#include "../libft.h"
void *ft_calloc(size_t nmemb, size_t size)
{
void *result;
size_t i;
i = 0;
if (nmemb == 0 || size == 0)
return (malloc(1));
if (((unsigned long long)(size * nmemb) > 4294967295))
return (NULL);
if ((int)size < 0 && (int)nmemb < 0)
return (NULL);
result = malloc(size * nmemb);
if (!result)
return (NULL);
while (i < (size * nmemb))
{
*(unsigned char *)(result + i) = '\0';
i++;
}
return (result);
}

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

@ -0,0 +1,27 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/05 14:52:53 by adjoly #+# #+# */
/* Updated: 2024/02/04 14:36:28 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#include "../libft.h"
void *ft_memchr(const void *s, int c, size_t n)
{
size_t i;
i = 0;
while (i < n)
{
if (((unsigned char *)s)[i] == (unsigned char)c)
return (((void *)s + i));
i++;
}
return (NULL);
}

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

@ -0,0 +1,25 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/08 12:04:48 by adjoly #+# #+# */
/* Updated: 2024/02/04 14:36:46 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#include "../libft.h"
int ft_memcmp(const void *s1, const void *s2, size_t n)
{
size_t i;
i = 0;
if (n == 0)
return (0);
while (((unsigned char *)s1)[i] == ((unsigned char *)s2)[i] && i < n - 1)
i++;
return (((unsigned char *)s1)[i] - ((unsigned char *)s2)[i]);
}

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

@ -0,0 +1,30 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/02 10:21:55 by adjoly #+# #+# */
/* Updated: 2024/02/04 15:00:19 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#include "../libft.h"
void *ft_memcpy(void *dest, const void *src, size_t n)
{
size_t i;
i = 0;
if (!src && !dest)
{
return (dest);
}
while (i < n)
{
((unsigned char *)dest)[i] = ((unsigned char *)src)[i];
i++;
}
return (dest);
}

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

@ -0,0 +1,27 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memmove.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/03 15:04:04 by adjoly #+# #+# */
/* Updated: 2024/02/04 14:38:10 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#include "../libft.h"
void *ft_memmove(void *dest, const void *src, size_t n)
{
size_t i;
i = -1;
if (dest > src)
while (n-- > 0)
((unsigned char *)dest)[n] = ((unsigned char *)src)[n];
else if (dest < src)
while (++i < n)
((unsigned char *)dest)[i] = ((unsigned char *)src)[i];
return (dest);
}

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

@ -0,0 +1,26 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memset.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/10/31 17:40:22 by adjoly #+# #+# */
/* Updated: 2024/02/04 14:37:55 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#include "../libft.h"
void *ft_memset(void *s, int c, size_t n)
{
size_t i;
i = 0;
while (i < n)
{
((char *)(s))[i] = c;
i++;
}
return (s);
}