debug ft_lstaddsort & lstsort
This commit is contained in:
parent
405c9b9717
commit
b1db252441
4
Makefile
4
Makefile
@ -6,12 +6,12 @@
|
|||||||
# By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ #
|
# By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ #
|
||||||
# +#+#+#+#+#+ +#+ #
|
# +#+#+#+#+#+ +#+ #
|
||||||
# Created: 2018/04/07 12:47:06 by tmaze #+# #+# #
|
# Created: 2018/04/07 12:47:06 by tmaze #+# #+# #
|
||||||
# Updated: 2018/10/01 12:35:21 by tmaze ### ########.fr #
|
# Updated: 2018/10/02 16:05:34 by tmaze ### ########.fr #
|
||||||
# #
|
# #
|
||||||
#******************************************************************************#
|
#******************************************************************************#
|
||||||
|
|
||||||
CC = gcc
|
CC = gcc
|
||||||
CCFLAGS = -Wall -Werror -Wextra
|
CCFLAGS = -Wall -Werror -Wextra -g
|
||||||
CCSTD =
|
CCSTD =
|
||||||
|
|
||||||
NAME = libft.a
|
NAME = libft.a
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2018/10/01 11:57:25 by tmaze #+# #+# */
|
/* Created: 2018/10/01 11:57:25 by tmaze #+# #+# */
|
||||||
/* Updated: 2018/10/01 13:10:02 by tmaze ### ########.fr */
|
/* Updated: 2018/10/02 16:43:09 by tmaze ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -15,13 +15,17 @@
|
|||||||
void ft_lstaddsort(t_list **lst, t_list *new, int (*f)(void *c1, void *c2),
|
void ft_lstaddsort(t_list **lst, t_list *new, int (*f)(void *c1, void *c2),
|
||||||
int rev)
|
int rev)
|
||||||
{
|
{
|
||||||
t_list *sorted;
|
t_list **sort;
|
||||||
|
|
||||||
sorted = *lst;
|
sort = lst;
|
||||||
if (rev)
|
if (*lst == NULL || (!rev && (*f)((*lst)->content, new->content) > 0)
|
||||||
ft_putstr("rev\n");
|
|| (rev && (*f)((*lst)->content, new->content) < 0))
|
||||||
while (sorted && (((*f)(sorted->content, new->content) >= 0 && rev))
|
|
||||||
|| (*f)(sorted->content, new->content) <= 0)
|
|
||||||
sorted = sorted->next;
|
|
||||||
ft_lstadd(lst, new);
|
ft_lstadd(lst, new);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
while ((*sort) && ((rev && (*f)((*sort)->content, new->content) >= 0)
|
||||||
|
|| (!rev && (*f)((*sort)->content, new->content) <= 0)))
|
||||||
|
sort = &(*sort)->next;
|
||||||
|
ft_lstadd(&(*sort), new);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user