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:
29
libft/src/stack/ft_stackadd_back.c
Normal file
29
libft/src/stack/ft_stackadd_back.c
Normal 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;
|
||||
}
|
26
libft/src/stack/ft_stackadd_front.c
Normal file
26
libft/src/stack/ft_stackadd_front.c
Normal 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;
|
||||
}
|
24
libft/src/stack/ft_stacklast.c
Normal file
24
libft/src/stack/ft_stacklast.c
Normal 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);
|
||||
}
|
26
libft/src/stack/ft_stacknew.c
Normal file
26
libft/src/stack/ft_stacknew.c
Normal 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);
|
||||
}
|
30
libft/src/stack/ft_stacksize.c
Normal file
30
libft/src/stack/ft_stacksize.c
Normal 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);
|
||||
}
|
Reference in New Issue
Block a user