mirror of
https://github.com/DavidGailleton/42-Push_Swap.git
synced 2026-01-27 00:41:57 +00:00
fixing the leak valgrind and conditionnal jump on some functions cause i forget to initialize the var to NULL i just need to remember this
This commit is contained in:
@@ -14,10 +14,5 @@
|
||||
|
||||
void bucket_algo(void)
|
||||
{
|
||||
/*int range;
|
||||
t_tab *preset;
|
||||
|
||||
range = range_bucket(piles->a);
|
||||
preset = get_tabs(piles->a, range);*/
|
||||
return ;
|
||||
}
|
||||
|
||||
@@ -34,8 +34,7 @@ int get_next_lower(t_stack *first, int old_lower)
|
||||
int next_lower;
|
||||
|
||||
tmp = first;
|
||||
next_lower = 2147483646;
|
||||
|
||||
next_lower = 2147483647;
|
||||
while (tmp->next != first)
|
||||
{
|
||||
if (old_lower < tmp->value && tmp->value <= next_lower)
|
||||
|
||||
@@ -20,13 +20,12 @@ t_tab *allocate_tab(int range_max, int nb)
|
||||
tab = malloc(sizeof(t_tab));
|
||||
if (!tab)
|
||||
return (NULL);
|
||||
tab->next = NULL;
|
||||
tab->max_range = range_max;
|
||||
tab->nb_in = nb;
|
||||
return (tab);
|
||||
}
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
t_tab *get_tabs(t_stack *first, int range)
|
||||
{
|
||||
t_tab *tmp;
|
||||
@@ -44,7 +43,7 @@ t_tab *get_tabs(t_stack *first, int range)
|
||||
{
|
||||
tmp->next = get_next_tab(first, tmp, range);
|
||||
if (!(tmp->next))
|
||||
return (free_tab(first_tab));
|
||||
return (free_tab(&first_tab));
|
||||
tmp = tmp->next;
|
||||
scan_nb_in_tab += tmp->nb_in;
|
||||
}
|
||||
@@ -78,15 +77,12 @@ t_tab *get_next_tab(t_stack *first, t_tab *tab, int range)
|
||||
return (next_tab);
|
||||
}
|
||||
|
||||
t_tab *free_tab(t_tab *first)
|
||||
t_tab *free_tab(t_tab **first)
|
||||
{
|
||||
t_tab *tmp;
|
||||
|
||||
while (first)
|
||||
{
|
||||
tmp = first->next;
|
||||
free(first);
|
||||
first = tmp;
|
||||
}
|
||||
if (!(*first))
|
||||
return (NULL);
|
||||
if ((*first)->next)
|
||||
free_tab(&(*first)->next);
|
||||
free(*first);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user