move functions
This commit is contained in:
45
srcs/utils.c
Normal file
45
srcs/utils.c
Normal 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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user