mirror of
https://github.com/DavidGailleton/42-Push_Swap.git
synced 2026-01-27 08:41:58 +00:00
fix conflict
This commit is contained in:
18
Makefile
18
Makefile
@@ -24,13 +24,13 @@ INCLUDES = headers
|
|||||||
# ALL FILES WITHOUT PATH
|
# ALL FILES WITHOUT PATH
|
||||||
#============================
|
#============================
|
||||||
|
|
||||||
SRC = main.c test_one.c
|
SRC = main.c test_one.c ft_putnbr.c secure_write.c
|
||||||
|
|
||||||
INSERTION = insertion.c
|
INSERTION = insertion.c
|
||||||
|
|
||||||
FLAGS_FILES = algorithms_sort.c flag.c
|
FLAGS_FILES = algorithms_sort.c flag.c bench.c
|
||||||
|
|
||||||
PARSING = ft_atoi.c parsing.c ft_strncmp.c ft_split.c ft_strlen.c ft_substr.c checker.c
|
PARSING = ft_atoi.c parsing.c ft_strncmp.c ft_split.c ft_strlen.c ft_substr.c checker.c ft_itoa.c ft_isdigit.c
|
||||||
|
|
||||||
STACK_UTILS = push.c rev_rotate.c rotate.c stack_add.c stack_remove.c stacks_len.c swap.c print_stacks.c
|
STACK_UTILS = push.c rev_rotate.c rotate.c stack_add.c stack_remove.c stacks_len.c swap.c print_stacks.c
|
||||||
|
|
||||||
@@ -46,7 +46,8 @@ ALGO_UTILS = check_order.c compare.c iterate.c pre_sort.c
|
|||||||
|
|
||||||
ALL_FILES = $(SRC) $(STACK_UTILS_DIR)/$(STACK_UTILS) $(PARS_DIR)/$(PARSING) \
|
ALL_FILES = $(SRC) $(STACK_UTILS_DIR)/$(STACK_UTILS) $(PARS_DIR)/$(PARSING) \
|
||||||
$(ALGO_DIR)/$(MEDIUM_DIR)/$(MEDIUM_ALGO) $(ALGO_UTILS_DIR)/$(ALGO_UTILS) \
|
$(ALGO_DIR)/$(MEDIUM_DIR)/$(MEDIUM_ALGO) $(ALGO_UTILS_DIR)/$(ALGO_UTILS) \
|
||||||
$(INSERT_DIR)/$(INSERTION) $(ALGO_DIR)/$(COMPLEX_DIR)/$(COMPLEX_ALGO)
|
$(INSERT_DIR)/$(INSERTION) $(ALGO_DIR)/$(COMPLEX_DIR)/$(COMPLEX_ALGO) \
|
||||||
|
$(FLAGS_DIR)/$(FLAGS_FILES)
|
||||||
|
|
||||||
OBJ_DIR = obj
|
OBJ_DIR = obj
|
||||||
|
|
||||||
@@ -69,9 +70,6 @@ $(NAME): $(OBJ)
|
|||||||
@echo "======= PUSH SWAP COMPILED ========="
|
@echo "======= PUSH SWAP COMPILED ========="
|
||||||
@echo "===================================="
|
@echo "===================================="
|
||||||
|
|
||||||
$(OBJ_DIR)/%.o: %.c | $(OBJ_DIR)
|
|
||||||
$(CC) $(CFLAGS) -MMD -MP -c $< -o $@
|
|
||||||
|
|
||||||
$(OBJ_DIR)/%.o: $(PARS_DIR)/%.c | $(OBJ_DIR)
|
$(OBJ_DIR)/%.o: $(PARS_DIR)/%.c | $(OBJ_DIR)
|
||||||
$(CC) $(CFLAGS) -MMD -MP -c $< -o $@
|
$(CC) $(CFLAGS) -MMD -MP -c $< -o $@
|
||||||
|
|
||||||
@@ -93,6 +91,12 @@ $(OBJ_DIR)/%.o: $(ALGO_DIR)/$(COMPLEX_DIR)/%.c | $(OBJ_DIR)
|
|||||||
$(OBJ_DIR)/%.o: $(ALGO_UTILS_DIR)/%.c | $(OBJ_DIR)
|
$(OBJ_DIR)/%.o: $(ALGO_UTILS_DIR)/%.c | $(OBJ_DIR)
|
||||||
$(CC) $(CFLAGS) -MMD -MP -c $< -o $@
|
$(CC) $(CFLAGS) -MMD -MP -c $< -o $@
|
||||||
|
|
||||||
|
$(OBJ_DIR)/%.o: $(FLAGS_DIR)/%.c | $(OBJ_DIR)
|
||||||
|
$(CC) $(CFLAGS) -MMD -MP -c $< -o $@
|
||||||
|
|
||||||
|
$(OBJ_DIR)/%.o: %.c | $(OBJ_DIR)
|
||||||
|
$(CC) $(CFLAGS) -MMD -MP -c $< -o $@
|
||||||
|
|
||||||
$(OBJ_DIR):
|
$(OBJ_DIR):
|
||||||
@mkdir -p $(OBJ_DIR)
|
@mkdir -p $(OBJ_DIR)
|
||||||
|
|
||||||
|
|||||||
@@ -6,12 +6,12 @@
|
|||||||
/* By: mteriier <mteriier@student.42lyon.fr> +#+ +:+ +#+ */
|
/* By: mteriier <mteriier@student.42lyon.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2026/01/07 12:15:02 by mteriier #+# #+# */
|
/* Created: 2026/01/07 12:15:02 by mteriier #+# #+# */
|
||||||
/* Updated: 2026/01/07 12:15:05 by mteriier ### ########lyon.fr */
|
/* Updated: 2026/01/08 16:07:00 by dgaillet ### ########lyon.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "push_swap.h"
|
#include "push_swap.h"
|
||||||
#include "medium_algo.h"
|
#include "medium_headers.h"
|
||||||
|
|
||||||
void simple(t_stacks *piles)
|
void simple(t_stacks *piles)
|
||||||
{
|
{
|
||||||
@@ -41,5 +41,7 @@ void complex(t_stacks *piles)
|
|||||||
|
|
||||||
void adaptive(t_stacks *piles)
|
void adaptive(t_stacks *piles)
|
||||||
{
|
{
|
||||||
|
(void)piles;
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
114
flags/bench.c
Normal file
114
flags/bench.c
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* bench.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2026/01/08 13:59:52 by dgaillet #+# #+# */
|
||||||
|
/* Updated: 2026/01/08 16:09:11 by dgaillet ### ########lyon.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "push_swap.h"
|
||||||
|
#include "parsing.h"
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
static void print_disorder(t_stacks *stacks)
|
||||||
|
{
|
||||||
|
int nbr;
|
||||||
|
char *str;
|
||||||
|
|
||||||
|
nbr = (int) stacks->disorder * 10000;
|
||||||
|
str = ft_itoa(nbr);
|
||||||
|
if (!str)
|
||||||
|
exit ( EXIT_FAILURE );
|
||||||
|
secure_write(2, "[bench] disorder: ", 18);
|
||||||
|
if (ft_strlen(str) == 2)
|
||||||
|
secure_write(2, "0", 1);
|
||||||
|
else
|
||||||
|
secure_write(2, str, ft_strlen(str) - 2);
|
||||||
|
secure_write(2, ".", 1);
|
||||||
|
secure_write(2, &str[ft_strlen(str) - 2], 2);
|
||||||
|
secure_write(2, "%\n", 2);
|
||||||
|
free(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void print_algo(t_stacks *stacks)
|
||||||
|
{
|
||||||
|
secure_write(2, "[bench] algo: ", 18);
|
||||||
|
if (stacks->algo == 0)
|
||||||
|
{
|
||||||
|
secure_write(2, "Adaptative", 10);
|
||||||
|
if (stacks->disorder < 0.2)
|
||||||
|
secure_write(2, " / O(n2n)\n", 10);
|
||||||
|
else if (stacks->disorder >= 0.5)
|
||||||
|
secure_write(2, " / O(n√n)\n", 10);
|
||||||
|
else
|
||||||
|
secure_write(2, " / O(nlogn)\n", 12);
|
||||||
|
}
|
||||||
|
else if (stacks->algo == 1)
|
||||||
|
secure_write(2, "Simple / O(n2n)\n", 16);
|
||||||
|
else if (stacks->algo == 2)
|
||||||
|
secure_write(2, "Medium / O(nlogn)\n", 18);
|
||||||
|
else if (stacks->algo == 3)
|
||||||
|
secure_write(2, "Complex / O(n√n)\n", 17);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void print_total_ops(t_stacks *stacks)
|
||||||
|
{
|
||||||
|
unsigned int total_ops;
|
||||||
|
|
||||||
|
total_ops = 0;
|
||||||
|
total_ops += stacks->sa;
|
||||||
|
total_ops += stacks->sb;
|
||||||
|
total_ops += stacks->ss;
|
||||||
|
total_ops += stacks->pa;
|
||||||
|
total_ops += stacks->pb;
|
||||||
|
total_ops += stacks->ra;
|
||||||
|
total_ops += stacks->rb;
|
||||||
|
total_ops += stacks->rr;
|
||||||
|
total_ops += stacks->rra;
|
||||||
|
total_ops += stacks->rrb;
|
||||||
|
total_ops += stacks->rrr;
|
||||||
|
secure_write(2, "[bench] total_ops: ", 18);
|
||||||
|
ft_putnbr_fd((int) total_ops, 2);
|
||||||
|
secure_write(2, "\n", 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void print_ops(t_stacks *stacks)
|
||||||
|
{
|
||||||
|
secure_write(2, "[bench] sa: ", 11);
|
||||||
|
ft_putnbr_fd((int) stacks->sa, 2);
|
||||||
|
secure_write(2, " sb: ", 5);
|
||||||
|
ft_putnbr_fd((int) stacks->sb, 2);
|
||||||
|
secure_write(2, " ss: ", 5);
|
||||||
|
ft_putnbr_fd((int) stacks->ss, 2);
|
||||||
|
secure_write(2, " pa: ", 5);
|
||||||
|
ft_putnbr_fd((int) stacks->pa, 2);
|
||||||
|
secure_write(2, " pb: ", 5);
|
||||||
|
ft_putnbr_fd((int) stacks->pb, 2);
|
||||||
|
secure_write(2, "\n", 1);
|
||||||
|
secure_write(2, "[bench] ra: ", 5);
|
||||||
|
ft_putnbr_fd((int) stacks->ra, 2);
|
||||||
|
secure_write(2, " rb: ", 5);
|
||||||
|
ft_putnbr_fd((int) stacks->rb, 2);
|
||||||
|
secure_write(2, " rr: ", 5);
|
||||||
|
ft_putnbr_fd((int) stacks->rr, 2);
|
||||||
|
secure_write(2, " rra: ", 6);
|
||||||
|
ft_putnbr_fd((int) stacks->rra, 2);
|
||||||
|
secure_write(2, " rrb: ", 6);
|
||||||
|
ft_putnbr_fd((int) stacks->rrb, 2);
|
||||||
|
secure_write(2, " rrr: ", 6);
|
||||||
|
ft_putnbr_fd((int) stacks->rrr, 2);
|
||||||
|
secure_write(2, "\n", 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_bench(t_stacks *stacks)
|
||||||
|
{
|
||||||
|
print_disorder(stacks);
|
||||||
|
print_algo(stacks);
|
||||||
|
print_total_ops(stacks);
|
||||||
|
print_ops(stacks);
|
||||||
|
}
|
||||||
@@ -6,12 +6,13 @@
|
|||||||
/* By: mteriier <mteriier@student.42lyon.fr> +#+ +:+ +#+ */
|
/* By: mteriier <mteriier@student.42lyon.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2026/01/07 12:39:29 by mteriier #+# #+# */
|
/* Created: 2026/01/07 12:39:29 by mteriier #+# #+# */
|
||||||
/* Updated: 2026/01/07 12:39:31 by mteriier ### ########lyon.fr */
|
/* Updated: 2026/01/08 16:07:29 by dgaillet ### ########lyon.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "push_swap.h"
|
#include "push_swap.h"
|
||||||
#include "parsing.h"
|
#include "parsing.h"
|
||||||
|
#include "flags.h"
|
||||||
|
|
||||||
static int verif_arg(char *argv)
|
static int verif_arg(char *argv)
|
||||||
{
|
{
|
||||||
|
|||||||
24
ft_putnbr.c
Normal file
24
ft_putnbr.c
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_putnbr.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2026/01/08 15:17:28 by dgaillet #+# #+# */
|
||||||
|
/* Updated: 2026/01/08 15:19:30 by dgaillet ### ########lyon.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "push_swap.h"
|
||||||
|
|
||||||
|
void ft_putnbr_fd(int nbr, int fd)
|
||||||
|
{
|
||||||
|
char c;
|
||||||
|
|
||||||
|
if (!nbr)
|
||||||
|
return ;
|
||||||
|
ft_putnbr_fd(nbr / 10, fd);
|
||||||
|
c = (nbr % 10) + '0';
|
||||||
|
secure_write(fd, &c, 1);
|
||||||
|
}
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: mteriier <mteriier@student.42lyon.fr> +#+ +:+ +#+ */
|
/* By: mteriier <mteriier@student.42lyon.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2026/01/07 13:05:52 by mteriier #+# #+# */
|
/* Created: 2026/01/07 13:05:52 by mteriier #+# #+# */
|
||||||
/* Updated: 2026/01/07 13:05:53 by mteriier ### ########lyon.fr */
|
/* Updated: 2026/01/08 15:32:54 by dgaillet ### ########lyon.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -22,4 +22,6 @@ int pos_bench(char **argv, int mod);
|
|||||||
int pos_flag(char **argv, int mod);
|
int pos_flag(char **argv, int mod);
|
||||||
int calcul_mod(int argc, char **argv);
|
int calcul_mod(int argc, char **argv);
|
||||||
|
|
||||||
|
void print_bench(t_stacks *stacks);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: mteriier <mteriier@student.42lyon.fr> +#+ +:+ +#+ */
|
/* By: mteriier <mteriier@student.42lyon.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2026/01/07 08:03:08 by mteriier #+# #+# */
|
/* Created: 2026/01/07 08:03:08 by mteriier #+# #+# */
|
||||||
/* Updated: 2026/01/08 12:56:19 by dgaillet ### ########lyon.fr */
|
/* Updated: 2026/01/08 14:15:37 by dgaillet ### ########lyon.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -25,5 +25,7 @@ char **ft_split(char const *s, char c);
|
|||||||
void free_tab(char **tab);
|
void free_tab(char **tab);
|
||||||
int checker(int argc, char **argv);
|
int checker(int argc, char **argv);
|
||||||
int len_split(char **tab);
|
int len_split(char **tab);
|
||||||
|
char *ft_itoa(int n);
|
||||||
|
int ft_isdigit(int c);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
|
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/12/08 14:18:06 by dgaillet #+# #+# */
|
/* Created: 2025/12/08 14:18:06 by dgaillet #+# #+# */
|
||||||
/* Updated: 2026/01/08 14:01:04 by dgaillet ### ########lyon.fr */
|
/* Updated: 2026/01/08 15:32:04 by dgaillet ### ########lyon.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -83,4 +83,7 @@ int test1(int argc, char **argv);
|
|||||||
/* RADIX */
|
/* RADIX */
|
||||||
void radix(t_stacks *stacks);
|
void radix(t_stacks *stacks);
|
||||||
|
|
||||||
|
void secure_write(int fd, char *str, int len);
|
||||||
|
void ft_putnbr_fd(int nbr, int fd);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
3
main.c
3
main.c
@@ -6,7 +6,7 @@
|
|||||||
/* By: mteriier <mteriier@student.42lyon.fr> +#+ +:+ +#+ */
|
/* By: mteriier <mteriier@student.42lyon.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/12/08 18:32:35 by mteriier #+# #+# */
|
/* Created: 2025/12/08 18:32:35 by mteriier #+# #+# */
|
||||||
/* Updated: 2026/01/08 12:57:04 by dgaillet ### ########lyon.fr */
|
/* Updated: 2026/01/08 15:34:59 by dgaillet ### ########lyon.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -21,7 +21,6 @@ int main(int argc, char **argv)
|
|||||||
write(2, "Error !\n", 8);
|
write(2, "Error !\n", 8);
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc > 1)
|
if (argc > 1)
|
||||||
test1(argc, argv);
|
test1(argc, argv);
|
||||||
return (0);
|
return (0);
|
||||||
|
|||||||
18
parsing/ft_isdigit.c
Normal file
18
parsing/ft_isdigit.c
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_isdigit.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2026/01/08 14:13:54 by dgaillet #+# #+# */
|
||||||
|
/* Updated: 2026/01/08 14:13:59 by dgaillet ### ########lyon.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
int ft_isdigit(int c)
|
||||||
|
{
|
||||||
|
if (c >= '0' && c <= '9')
|
||||||
|
return (1);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
62
parsing/ft_itoa.c
Normal file
62
parsing/ft_itoa.c
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_itoa.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2026/01/08 14:13:00 by dgaillet #+# #+# */
|
||||||
|
/* Updated: 2026/01/08 14:13:27 by dgaillet ### ########lyon.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
static size_t count_digits(int n)
|
||||||
|
{
|
||||||
|
size_t size;
|
||||||
|
|
||||||
|
size = 0;
|
||||||
|
if (n <= 0)
|
||||||
|
size++;
|
||||||
|
while (n)
|
||||||
|
{
|
||||||
|
n /= 10;
|
||||||
|
size++;
|
||||||
|
}
|
||||||
|
return (size);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void insert_char(char *str, unsigned int nbr, size_t index)
|
||||||
|
{
|
||||||
|
while (nbr)
|
||||||
|
{
|
||||||
|
str[index--] = nbr % 10 + '0';
|
||||||
|
nbr /= 10;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
char *ft_itoa(int n)
|
||||||
|
{
|
||||||
|
unsigned int nbr;
|
||||||
|
char *str;
|
||||||
|
size_t size;
|
||||||
|
|
||||||
|
nbr = n;
|
||||||
|
if (n < 0)
|
||||||
|
nbr = n * -1;
|
||||||
|
size = count_digits(n);
|
||||||
|
str = malloc(sizeof(char) * (size + 1));
|
||||||
|
if (!str)
|
||||||
|
return (NULL);
|
||||||
|
str[size] = '\0';
|
||||||
|
if (nbr == 0)
|
||||||
|
str[0] = '0';
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (n < 0)
|
||||||
|
str[0] = '-';
|
||||||
|
insert_char(str, nbr, size - 1);
|
||||||
|
}
|
||||||
|
return (str);
|
||||||
|
}
|
||||||
20
secure_write.c
Normal file
20
secure_write.c
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* secure_write.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2026/01/08 14:30:38 by dgaillet #+# #+# */
|
||||||
|
/* Updated: 2026/01/08 14:32:19 by dgaillet ### ########lyon.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
void secure_write(int fd, char *str, int len)
|
||||||
|
{
|
||||||
|
if (write(fd, str, len) < 0)
|
||||||
|
exit ( EXIT_FAILURE );
|
||||||
|
}
|
||||||
@@ -6,11 +6,12 @@
|
|||||||
/* By: mteriier <mteriier@student.lyon42.fr> +#+ +:+ +#+ */
|
/* By: mteriier <mteriier@student.lyon42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/12/22 12:33:58 by mteriier #+# #+# */
|
/* Created: 2025/12/22 12:33:58 by mteriier #+# #+# */
|
||||||
/* Updated: 2026/01/08 12:57:57 by dgaillet ### ########lyon.fr */
|
/* Updated: 2026/01/08 15:35:43 by dgaillet ### ########lyon.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "push_swap.h"
|
#include "push_swap.h"
|
||||||
|
#include "flags.h"
|
||||||
#include "parsing.h"
|
#include "parsing.h"
|
||||||
#include "medium_headers.h"
|
#include "medium_headers.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -25,6 +26,7 @@ int test1(int argc, char **argv)
|
|||||||
if (argc > 1)
|
if (argc > 1)
|
||||||
{
|
{
|
||||||
piles = init_piles(argc, argv, 0);
|
piles = init_piles(argc, argv, 0);
|
||||||
|
print_bench(piles);
|
||||||
preset = get_tabs(piles->a, range_bucket(piles->a));
|
preset = get_tabs(piles->a, range_bucket(piles->a));
|
||||||
bucket_algo(piles, preset, range_bucket(piles->a));
|
bucket_algo(piles, preset, range_bucket(piles->a));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user