move functions

This commit is contained in:
2025-04-26 19:53:55 +02:00
parent 621b9fc4ee
commit 4e344d945e
5 changed files with 100 additions and 72 deletions

45
srcs/utils.c Normal file
View File

@ -0,0 +1,45 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tomoron <tomoron@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/26 17:03:11 by tomoron #+# #+# */
/* Updated: 2025/04/26 17:08:08 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
#include "includes/ft_ping.h"
int add_host(t_settings *res, char *host)
{
t_host_list *new;
t_host_list *tmp;
new = malloc(sizeof(t_host_list));
if(!new)
return(0);
new->host = host;
new->next = 0;
tmp = res->hosts;
while(tmp && tmp->next)
tmp = tmp->next;
if(tmp)
tmp->next = new;
else
res->hosts = new;
return(1);
}
void free_hosts(t_host_list *list)
{
t_host_list *tmp;
while(list)
{
printf("free : %s\n", list->host);
tmp = list->next;
free(list);
list = tmp;
}
}