Skip to content

Commit

Permalink
comentarios
Browse files Browse the repository at this point in the history
  • Loading branch information
evertonportela committed Oct 18, 2023
1 parent 9fd85ef commit 0ecc8a8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
22 changes: 19 additions & 3 deletions sources/ft_clean_struct.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,55 @@

#include "push_swap.h"

/**
* Função auxiliar para limpar a lista encadeada
*/
static void ft_clean_list(t_stack **list)
{
t_stack *aux;
t_stack *temp;

aux = *list;
// Se a lista estiver vazia, não há nada a fazer
if (aux == NULL)
return ;
while (aux != NULL)
{
temp = aux->next;
// Libera a memória alocada para o nó atual
free(aux);
aux = temp;
}
// Define o ponteiro da lista como NULL para indicar que está vazia
*list = NULL;
}

/**
* Função para limpar a estrutura principal e arrays associados
*/
void ft_clean_project(t_stack_pack *pack, int *array_num, int *start_index,
char **array_bin)
char **array_bin)
{
int index;

// Libera a memória alocada para o array 'start_index'
free(start_index);
// start_index = NULL;
// Libera a memória alocada para o array 'array_num'
free(array_num);
// array_num = NULL;

/* Chama a função para limpar a lista encadeada 'stack_a'
* dentro da estrutura 'pack' */
ft_clean_list(&pack->stack_a);
/* Chama a função para limpar a lista encadeada 'stack_b'
* dentro da estrutura 'pack' */
ft_clean_list(&pack->stack_b);
index = 0;
while (index < pack->length)
{
// Libera a memória alocada para cada string no array 'array_bin'
free(array_bin[index]);
index++;
}
// Libera a memória alocada para o array 'array_bin'
free(array_bin);
}
4 changes: 2 additions & 2 deletions sources/ft_make_binaries.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: evportel <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/10/14 15:27:59 by evportel #+# #+# */
/* Updated: 2023/10/15 15:28:01 by evportel ### ########.fr */
/* Updated: 2023/10/18 20:05:36 by evportel ### ########.fr */
/* */
/* ************************************************************************** */

Expand All @@ -17,7 +17,7 @@
* pode ser dividido por '2', antes de se tornar zero.
* Será usado para determinar o tamanho da alocação de memória necessária.
*/
static int ft_find_limit(int length)
int ft_find_limit(int length)
{
int limit;

Expand Down

0 comments on commit 0ecc8a8

Please sign in to comment.