Skip to content

Latest commit

 

History

History
30 lines (28 loc) · 686 Bytes

File metadata and controls

30 lines (28 loc) · 686 Bytes

Project 9: Philosophers - Ninth project for the formation of software engineers at school 42 São Paulo.

🏠 home    

/**
 * It frees the data structure and the linked list of philosophers
 * 
 * @param data a pointer to a t_data struct
 */
void	free_all(t_data *data)
{
	if (data->number_of_philosophers == 1)
	{
		free(data->philo);
		free (data);
	}
	else
	{
		while (data->number_of_philosophers > 1)
		{
			data->philo = data->philo->next;
			free (data->philo->prev);
			data->number_of_philosophers--;
		}
		free(data->philo);
		free(data);
	}
}