leaks and leaks with errors should be ok
This commit is contained in:
Binary file not shown.
BIN
builds/stop.o
BIN
builds/stop.o
Binary file not shown.
@@ -1,13 +1,5 @@
|
|||||||
#include "push_swap.h"
|
#include "push_swap.h"
|
||||||
|
|
||||||
// check more error
|
|
||||||
void is_valid(int ac, char **av)
|
|
||||||
{
|
|
||||||
if (ac < 2)
|
|
||||||
ps_stop(NULL, 1);
|
|
||||||
(void)av;
|
|
||||||
}
|
|
||||||
|
|
||||||
int check_flag(int *ac, char ***av)
|
int check_flag(int *ac, char ***av)
|
||||||
{
|
{
|
||||||
if (ft_strcmp((*av)[1], "-p") == 0)
|
if (ft_strcmp((*av)[1], "-p") == 0)
|
||||||
@@ -32,19 +24,16 @@ t_stack *fill_stack(t_stack *list, char *nb)
|
|||||||
|
|
||||||
new = ft_calloc(1, sizeof(t_stack));
|
new = ft_calloc(1, sizeof(t_stack));
|
||||||
if (!new)
|
if (!new)
|
||||||
ps_stop((t_list *)list, 2);
|
ps_stop((t_list *)list, 3);
|
||||||
|
|
||||||
/*
|
|
||||||
if (ft_isnumber(nb) == 0)
|
|
||||||
ps_stop((t_list *)list, 2);
|
|
||||||
nbl = ft_atol(nb);
|
|
||||||
if (nbl < INT_MIN || nbl > INT_MAX)
|
|
||||||
ps_stop((t_list *)list, 2);
|
|
||||||
new->n = nbl;
|
|
||||||
new->limit = 0;
|
|
||||||
new->next = list;
|
new->next = list;
|
||||||
list = new;
|
list = new;
|
||||||
*/
|
if (ft_isnumber(nb) == 0)
|
||||||
|
ps_stop((t_list *)list, 3);
|
||||||
|
nbl = ft_atol(nb);
|
||||||
|
if (nbl < INT_MIN || nbl > INT_MAX)
|
||||||
|
ps_stop((t_list *)list, 3);
|
||||||
|
list->n = nbl;
|
||||||
|
list->limit = 0;
|
||||||
return (list);
|
return (list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,7 +91,8 @@ int main(int ac, char **av)
|
|||||||
t_list *solution;
|
t_list *solution;
|
||||||
int flag;
|
int flag;
|
||||||
|
|
||||||
is_valid(ac, av);
|
if (ac < 2)
|
||||||
|
ps_stop(NULL, 1);
|
||||||
flag = check_flag(&ac, &av);
|
flag = check_flag(&ac, &av);
|
||||||
a = init_stack(ac, av);
|
a = init_stack(ac, av);
|
||||||
b = NULL;
|
b = NULL;
|
||||||
|
|||||||
@@ -4,22 +4,22 @@ void ps_error(int err)
|
|||||||
{
|
{
|
||||||
if (err == 1)
|
if (err == 1)
|
||||||
ft_printf("usage :\nlaunch executable : ./push_swap [flag -p] nb nb nb nb nb ...\n");
|
ft_printf("usage :\nlaunch executable : ./push_swap [flag -p] nb nb nb nb nb ...\n");
|
||||||
if (err == 2)
|
if (err >= 2)
|
||||||
ft_putstr_fd("Error\n", 2);
|
ft_putstr_fd("Error\n", 2);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** if err < 0, the parameter list is just a t_stack *list
|
|
||||||
** if err = 0, the list are freed but the program doesn't stop
|
** if err = 0, the list are freed but the program doesn't stop
|
||||||
** if err > 0, a message is printed and the program stop
|
** if err = 1, 2 or 3, a message is printed and the program stop
|
||||||
|
** if err = 3, the parameter list is just a t_stack *list
|
||||||
*/
|
*/
|
||||||
void ps_stop(t_list *lst, int err)
|
void ps_stop(t_list *lst, int err)
|
||||||
{
|
{
|
||||||
t_stack **a;
|
t_stack **a;
|
||||||
t_stack **b;
|
t_stack **b;
|
||||||
|
|
||||||
if (err < 0)
|
if (err == 3)
|
||||||
ft_lstclear(&lst, NULL);
|
ft_lstclear(&lst, NULL);
|
||||||
else if (lst)
|
else if (lst)
|
||||||
{
|
{
|
||||||
|
|||||||
10
tester.sh
10
tester.sh
@@ -12,15 +12,19 @@ WHITE='\033[1;37m'
|
|||||||
NC='\033[0m'
|
NC='\033[0m'
|
||||||
|
|
||||||
# usage of arguments
|
# usage of arguments
|
||||||
if [ $# -eq 2 ]
|
if [ $# -eq 1 ]
|
||||||
then
|
then
|
||||||
PRGM=$1 # path to program
|
SIZE=$1 # size of the list
|
||||||
SIZE=$2 # size of the list
|
elif [ $# -eq 2 ]
|
||||||
|
then
|
||||||
|
FLAG=$1 # flag for leaks and errors // not in use so far
|
||||||
|
SIZE=$2
|
||||||
else
|
else
|
||||||
echo "usage : ./tester.sh path/to/push_swap size_of_list"
|
echo "usage : ./tester.sh path/to/push_swap size_of_list"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
PRGM=push_swap # path to program
|
||||||
# range of random numbers
|
# range of random numbers
|
||||||
RANGE=$(($SIZE * 2))
|
RANGE=$(($SIZE * 2))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user