Dernier correction tout fini (:

This commit is contained in:
Etienne Rey-bethbeder 2022-12-11 15:58:47 +01:00
parent e517983764
commit abbb8d13d4
3 changed files with 17 additions and 6 deletions

View file

@ -6,7 +6,7 @@
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */ /* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/23 16:48:12 by erey-bet #+# #+# */ /* Created: 2022/11/23 16:48:12 by erey-bet #+# #+# */
/* Updated: 2022/12/08 16:57:34 by erey-bet ### ########.fr */ /* Updated: 2022/12/11 15:51:26 by erey-bet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -83,11 +83,11 @@ void push_swap_5(long *tab, int len)
t_stack sb; t_stack sb;
sa.list = get_index(tab, len); sa.list = get_index(tab, len);
sa.len = len; if (sa.list == NULL)
sb.list = malloc(sizeof(long) * (len + 1)); return ;
if (sb.list == NULL) sa.len = len;
if (init_sb(&sb, len) == NULL)
return ; return ;
sb.len = 0;
while (sb.len != 2) while (sb.len != 2)
{ {
while (get_min(sa.list, sa.len) != 0) while (get_min(sa.list, sa.len) != 0)

View file

@ -44,6 +44,8 @@ int tab_malloc(int argc, char *argv[]);
int put_error(void); int put_error(void);
char **set_only_space(char *argv[], int i); char **set_only_space(char *argv[], int i);
int if_there_is_double(long *tab, int y); int if_there_is_double(long *tab, int y);
void *init_sb(t_stack *sb, int len);
// Parsing // Parsing
int parsing(int argc, char *argv[], long *tab); int parsing(int argc, char *argv[], long *tab);

View file

@ -6,7 +6,7 @@
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */ /* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2022/12/09 15:54:00 by erey-bet #+# #+# */ /* Created: 2022/12/09 15:54:00 by erey-bet #+# #+# */
/* Updated: 2022/12/09 15:54:03 by erey-bet ### ########.fr */ /* Updated: 2022/12/11 15:51:37 by erey-bet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -48,3 +48,12 @@ int if_there_is_double(long *tab, int y)
} }
return (0); return (0);
} }
void *init_sb(t_stack *sb, int len)
{
sb->list = malloc(sizeof(long) * (len + 1));
if (sb->list == NULL)
return (NULL);
sb->len = 0;
return (sb);
}