1
0
mirror of https://github.com/KeyZox71/ft_minipowershell.git synced 2025-05-14 00:08:47 +02:00

🔨」 fix(libft): replaced libft by a better one :D

This commit is contained in:
y-syo
2024-04-29 13:53:00 +02:00
parent 77786466e3
commit 73bb992b01
77 changed files with 1511 additions and 1320 deletions

View File

@ -0,0 +1,29 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_stackadd_back.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mmoussou <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/18 00:36:32 by mmoussou #+# #+# */
/* Updated: 2024/01/18 00:39:38 by mmoussou ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_stackadd_back(t_stack **stack, t_stack *new)
{
t_stack *tmp;
if (!stack || !new)
return ;
if (!*stack)
{
*stack = new;
return ;
}
tmp = *stack;
tmp = ft_stacklast(*stack);
tmp->next = new;
}

View File

@ -0,0 +1,26 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_stackadd_front.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mmoussou <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/18 00:36:50 by mmoussou #+# #+# */
/* Updated: 2024/01/18 00:37:05 by mmoussou ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_stackadd_front(t_stack **stack, t_stack *new)
{
t_stack *tmp;
tmp = *stack;
*stack = new;
if (!new || !stack)
return ;
while (new->next)
new = new->next;
new->next = tmp;
}

View File

@ -0,0 +1,24 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_stacklast.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mmoussou <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/18 00:36:13 by mmoussou #+# #+# */
/* Updated: 2024/01/18 00:36:15 by mmoussou ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
t_stack *ft_stacklast(t_stack *stack)
{
if (stack)
{
while (stack->next)
stack = stack->next;
return (stack);
}
return (NULL);
}

View File

@ -0,0 +1,26 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_stacknew.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mmoussou <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/18 00:35:18 by mmoussou #+# #+# */
/* Updated: 2024/01/18 00:35:30 by mmoussou ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
t_stack *ft_stacknew(int content)
{
t_stack *new_element;
new_element = malloc(sizeof(t_stack));
if (!new_element)
return (NULL);
new_element->nb_init = content;
new_element->nb = -1;
new_element->next = NULL;
return (new_element);
}

View File

@ -0,0 +1,30 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_stacksize.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/18 00:35:55 by mmoussou #+# #+# */
/* Updated: 2024/04/11 14:35:24 by mmoussou ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
uint ft_stacksize(t_stack *stack)
{
uint i;
i = 0;
if (stack)
{
i++;
while (stack->next)
{
stack = stack->next;
i++;
}
}
return (i);
}