Exemplo n.º 1
0
t_list	*ft_lstreverse(t_list *lst)
{
	t_list	*list;
	t_list	*tmp;
	t_list	*elem;
	size_t	i;
	size_t	j;

	list = NULL;
	if (lst == NULL)
		return (NULL);
	tmp = lst;
	i = ft_lstlen(lst);
	while (i > 0)
	{
		j = 1;
		while (j++ < i)
			lst = lst->next;
		elem = ft_lstnew(lst->content, lst->content_size);
		if (elem == NULL)
			return (NULL);
		ft_lstaddback(&list, elem);
		i--;
		lst = tmp;
	}
	return (list);
}
Exemplo n.º 2
0
Arquivo: lexer.c Projeto: qstemper/42
t_list		*tokenlst(t_list **list, t_token *token)
{
	t_list	*elem;

	if ((elem = ft_lstnew((void *)token, sizeof(t_token))) == NULL)
	{
		*list = NULL;
		return (NULL);
	}
	ft_lstaddback(list, elem);
	return (*list);
}
Exemplo n.º 3
0
static int		read_to_lst(t_fd *fdatas)
{
	t_lst	*new_lst;
	char	*buffer;

	buffer = (char *)malloc(FILE_BUFF_SIZE + 1);
	if (buffer == NULL)
		return (-1);
	new_lst = ft_lstnew(buffer);
	if (new_lst == NULL)
		return (-1);
	ft_lstaddback(&(fdatas->lst), new_lst);
	return (read(fdatas->fd, (char *)(new_lst->data), FILE_BUFF_SIZE));
}
Exemplo n.º 4
0
int			ps_build_list(char **argv, t_list **lst)
{
	t_list	*elt;
	int		curr_v;

	*lst = NULL;
	while (*(++argv))
	{
		if (catoi(*argv, &curr_v) == -1)
			return (-1);
		if (!(elt = ft_lstnew(&curr_v, sizeof(curr_v))))
			return (-1);
		ft_lstaddback(lst, elt);
	}
	return (check_doubloons(*lst));
}