From fad52efb165e848ef054d5d65bfe8fa337f753df Mon Sep 17 00:00:00 2001 From: Jack Halford Date: Fri, 3 Mar 2017 16:59:05 +0100 Subject: [PATCH] push and pop changed --- libftasm/includes/lst.h | 4 ++-- libftasm/src/lst/ft_id.c | 2 +- libftasm/src/lst/ft_lst_filter.c | 2 +- libftasm/src/lst/ft_lstdelone.c | 2 +- libftasm/src/lst/ft_lstmap.c | 2 +- libftasm/src/lst/pop.c | 9 ++++++--- libftasm/src/lst/push.c | 2 +- 7 files changed, 13 insertions(+), 10 deletions(-) diff --git a/libftasm/includes/lst.h b/libftasm/includes/lst.h index f8ceb753..ef3ccf6d 100644 --- a/libftasm/includes/lst.h +++ b/libftasm/includes/lst.h @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/07 13:27:46 by jhalford #+# #+# */ -/* Updated: 2017/02/10 00:32:53 by jhalford ### ########.fr */ +/* Updated: 2017/03/03 13:36:18 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -24,7 +24,7 @@ struct s_list typedef struct s_list t_list; -t_list *pop(t_list **lst); +int pop(t_list **lst); t_list *push(t_list **stack, int elem); t_list *ft_lstnew(void const *content, size_t content_size); diff --git a/libftasm/src/lst/ft_id.c b/libftasm/src/lst/ft_id.c index a1a622a7..367202d8 100644 --- a/libftasm/src/lst/ft_id.c +++ b/libftasm/src/lst/ft_id.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/04 11:08:55 by jhalford #+# #+# */ -/* Updated: 2016/11/04 11:10:25 by jhalford ### ########.fr */ +/* Updated: 2017/03/02 17:47:34 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/libftasm/src/lst/ft_lst_filter.c b/libftasm/src/lst/ft_lst_filter.c index 39b6149f..f0004126 100644 --- a/libftasm/src/lst/ft_lst_filter.c +++ b/libftasm/src/lst/ft_lst_filter.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/04 11:09:17 by jhalford #+# #+# */ -/* Updated: 2017/01/09 12:33:31 by jhalford ### ########.fr */ +/* Updated: 2017/03/02 17:47:26 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/libftasm/src/lst/ft_lstdelone.c b/libftasm/src/lst/ft_lstdelone.c index 405991a3..957abec9 100644 --- a/libftasm/src/lst/ft_lstdelone.c +++ b/libftasm/src/lst/ft_lstdelone.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/05 13:39:33 by jhalford #+# #+# */ -/* Updated: 2016/12/05 13:43:03 by jhalford ### ########.fr */ +/* Updated: 2017/03/03 13:34:45 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/libftasm/src/lst/ft_lstmap.c b/libftasm/src/lst/ft_lstmap.c index 3b6b06c1..689c64ae 100644 --- a/libftasm/src/lst/ft_lstmap.c +++ b/libftasm/src/lst/ft_lstmap.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/03 14:57:21 by jhalford #+# #+# */ -/* Updated: 2017/01/09 12:30:20 by jhalford ### ########.fr */ +/* Updated: 2017/03/02 17:48:58 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/libftasm/src/lst/pop.c b/libftasm/src/lst/pop.c index a78bb6fc..148d6d7c 100644 --- a/libftasm/src/lst/pop.c +++ b/libftasm/src/lst/pop.c @@ -6,18 +6,21 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/04 11:09:56 by jhalford #+# #+# */ -/* Updated: 2017/02/10 00:33:21 by jhalford ### ########.fr */ +/* Updated: 2017/03/03 16:49:59 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" -t_list *pop(t_list **lst) +int pop(t_list **lst) { t_list *top; + int item; top = *lst; + item = top ? *(int*)top->content : 0; if (lst && *lst) *lst = (*lst)->next; - return (top); + ft_lstdelone(&top, ft_lst_cfree); + return (item); } diff --git a/libftasm/src/lst/push.c b/libftasm/src/lst/push.c index a99f77aa..111b3505 100644 --- a/libftasm/src/lst/push.c +++ b/libftasm/src/lst/push.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/09 15:59:39 by jhalford #+# #+# */ -/* Updated: 2017/02/20 17:19:25 by jhalford ### ########.fr */ +/* Updated: 2017/03/02 20:59:42 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */