merging ralentit branch
This commit is contained in:
@@ -1,12 +1,12 @@
|
|||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
/* */
|
/* */
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* bonus.c :+: :+: :+: */
|
/* f_bonus_opti.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2019/05/24 14:42:46 by hulamy #+# #+# */
|
/* Created: 2019/06/01 14:06:37 by hulamy #+# #+# */
|
||||||
/* Updated: 2019/06/01 12:31:29 by hulamy ### ########.fr */
|
/* Updated: 2019/06/01 14:06:40 by hulamy ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -25,7 +25,6 @@ int check_tetri_memory(t_fillist *list, int pos)
|
|||||||
mask = 1 << ((pos % 32) - 1);
|
mask = 1 << ((pos % 32) - 1);
|
||||||
if (tetri->same)
|
if (tetri->same)
|
||||||
{
|
{
|
||||||
// ft_putstr("tetri->same->memory"); ft_putstr((char *)tetri->same->memory); ft_putstr(" -- "); ft_putnbrendl(pos / 32);
|
|
||||||
if (!(tetri->same->memory[pos / 32] & mask))
|
if (!(tetri->same->memory[pos / 32] & mask))
|
||||||
return (tetri->same->memory[pos / 32] |= mask);
|
return (tetri->same->memory[pos / 32] |= mask);
|
||||||
}
|
}
|
||||||
@@ -52,6 +51,21 @@ int compare_tetri(t_fillist *tetri_a, t_fillist *tetri_b)
|
|||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Function that free the list->memory each time it's malloc
|
||||||
|
*/
|
||||||
|
|
||||||
|
t_fillist *clean_list_memory(t_fillist *list, t_fillist *tmp)
|
||||||
|
{
|
||||||
|
while (tmp)
|
||||||
|
{
|
||||||
|
if (tmp->memory)
|
||||||
|
free(tmp->memory);
|
||||||
|
tmp = tmp->next;
|
||||||
|
}
|
||||||
|
return (list);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Test optimisation for not testing wrong maps when tetri are identical
|
** Test optimisation for not testing wrong maps when tetri are identical
|
||||||
*/
|
*/
|
||||||
@@ -62,7 +76,7 @@ int check_same_tetri(t_fillist *list, int num)
|
|||||||
t_fillist *next_tetri;
|
t_fillist *next_tetri;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
curr_tetri = list;
|
curr_tetri = clean_list_memory(list, list);
|
||||||
while (curr_tetri != NULL)
|
while (curr_tetri != NULL)
|
||||||
{
|
{
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */
|
/* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2019/04/15 14:48:14 by vmanzoni #+# #+# */
|
/* Created: 2019/04/15 14:48:14 by vmanzoni #+# #+# */
|
||||||
/* Updated: 2019/05/29 19:08:15 by hulamy ### ########.fr */
|
/* Updated: 2019/06/01 14:06:07 by hulamy ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: hulamy <hulamy@student.42.fr> +#+ +:+ +#+ */
|
/* By: hulamy <hulamy@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2019/04/30 13:24:28 by hulamy #+# #+# */
|
/* Created: 2019/04/30 13:24:28 by hulamy #+# #+# */
|
||||||
/* Updated: 2019/05/29 19:10:33 by hulamy ### ########.fr */
|
/* Updated: 2019/06/01 14:05:45 by hulamy ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -98,8 +98,8 @@ void print_letter_map(t_fillist *list, int size, int flag)
|
|||||||
ft_putchar(' ');
|
ft_putchar(' ');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free(map);
|
|
||||||
ft_putchar('\n');
|
ft_putchar('\n');
|
||||||
|
free(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: hulamy <hulamy@student.42.fr> +#+ +:+ +#+ */
|
/* By: hulamy <hulamy@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2019/04/27 20:47:22 by hulamy #+# #+# */
|
/* Created: 2019/04/27 20:47:22 by hulamy #+# #+# */
|
||||||
/* Updated: 2019/05/29 18:28:04 by hulamy ### ########.fr */
|
/* Updated: 2019/06/01 14:04:53 by hulamy ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|||||||
4
fillit.h
4
fillit.h
@@ -6,7 +6,7 @@
|
|||||||
/* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */
|
/* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2019/03/01 13:34:46 by vmanzoni #+# #+# */
|
/* Created: 2019/03/01 13:34:46 by vmanzoni #+# #+# */
|
||||||
/* Updated: 2019/06/01 12:27:09 by hulamy ### ########.fr */
|
/* Updated: 2019/06/01 14:03:45 by hulamy ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -94,6 +94,7 @@ int print_flags_usage(void);
|
|||||||
*/
|
*/
|
||||||
int check_tetri_memory(t_fillist *list, int pos);
|
int check_tetri_memory(t_fillist *list, int pos);
|
||||||
int compare_tetri(t_fillist *tetri_a, t_fillist *tetri_b);
|
int compare_tetri(t_fillist *tetri_a, t_fillist *tetri_b);
|
||||||
|
t_fillist *clean_list_memory(t_fillist *list, t_fillist *tmp);
|
||||||
int check_same_tetri(t_fillist *list, int num);
|
int check_same_tetri(t_fillist *list, int num);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -101,6 +102,7 @@ int check_same_tetri(t_fillist *list, int num);
|
|||||||
*/
|
*/
|
||||||
int main(int argc, char **argv);
|
int main(int argc, char **argv);
|
||||||
int *create_dope(char *av, int mdp);
|
int *create_dope(char *av, int mdp);
|
||||||
|
void clean_list(t_fillist *list, t_fillist *tmp);
|
||||||
int is_mdp(int ac, char **av);
|
int is_mdp(int ac, char **av);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
20
main.c
20
main.c
@@ -6,7 +6,7 @@
|
|||||||
/* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */
|
/* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2019/02/12 13:20:48 by vmanzoni #+# #+# */
|
/* Created: 2019/02/12 13:20:48 by vmanzoni #+# #+# */
|
||||||
/* Updated: 2019/05/29 19:09:11 by hulamy ### ########.fr */
|
/* Updated: 2019/06/01 13:58:49 by hulamy ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -66,6 +66,22 @@ int is_mdp(int ac, char **av)
|
|||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Function that free the list
|
||||||
|
*/
|
||||||
|
|
||||||
|
void clean_list(t_fillist *list, t_fillist *tmp)
|
||||||
|
{
|
||||||
|
tmp = list;
|
||||||
|
while (list)
|
||||||
|
{
|
||||||
|
list = tmp->next;
|
||||||
|
free(tmp->memory);
|
||||||
|
free(tmp);
|
||||||
|
tmp = list;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Main function
|
** Main function
|
||||||
*/
|
*/
|
||||||
@@ -88,8 +104,10 @@ int main(int ac, char **av)
|
|||||||
size = parse_input(input, &list, dope);
|
size = parse_input(input, &list, dope);
|
||||||
print_final_map(list, size);
|
print_final_map(list, size);
|
||||||
free(input);
|
free(input);
|
||||||
|
clean_list(list, list);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
print_error("usage: Please submit a file.\n> ./fillit file.fillit\n");
|
print_error("usage: Please submit a file.\n> ./fillit file.fillit\n");
|
||||||
|
free(dope);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user