free everything in day 10-15

This commit is contained in:
2024-12-15 19:13:01 +01:00
parent b6b46e0d82
commit 5c411be678
7 changed files with 45 additions and 11 deletions

View File

@ -6,7 +6,7 @@
/* By: tomoron <tomoron@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/07/17 23:03:36 by tomoron #+# #+# */
/* Updated: 2024/12/11 22:19:45 by tomoron ### ########.fr */
/* Updated: 2024/12/15 19:02:21 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
@ -101,6 +101,7 @@ long int resolve_part1(char *input, char **split)
(void)split;
(void)input;
t_pebble *pebble;
t_pebble *tmp;
pebble = get_input(input);
long int res;
(void)get_input;
@ -108,8 +109,10 @@ long int resolve_part1(char *input, char **split)
res = 0;
while(pebble)
{
tmp = pebble->next;
res += get_nb(pebble->value, 0);
pebble = pebble->next;
free(pebble);
pebble = tmp;
}
return(res);
}

View File

@ -6,7 +6,7 @@
/* By: tomoron <tomoron@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/07/17 23:03:36 by tomoron #+# #+# */
/* Updated: 2024/12/11 22:52:44 by tomoron ### ########.fr */
/* Updated: 2024/12/15 19:02:10 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
@ -112,6 +112,7 @@ long int resolve_part2(char *input, char **split)
(void)split;
(void)input;
t_pebble *pebble;
t_pebble *tmp;
long int res;
long int *map;
size_t map_len;
@ -124,8 +125,10 @@ long int resolve_part2(char *input, char **split)
bzero(map, map_len);
while(pebble)
{
tmp = pebble->next;
res += get_nb(pebble->value, 0, map);
pebble = pebble->next;
free(pebble);
pebble = tmp;
}
free(map);
return(res);