-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_lstfrom_mapkeys_byvalue.c
37 lines (34 loc) · 1.33 KB
/
ft_lstfrom_mapkeys_byvalue.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstfrom_mapkeys_byvalue.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tle-meur <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/23 14:49:41 by tle-meur #+# #+# */
/* Updated: 2015/11/23 14:55:43 by tle-meur ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
t_list *ft_lstfrom_mapkeys_byvalue(t_map *map, t_data *value)
{
t_data tmp;
t_list *lst;
t_list *add;
if (!value)
return (NULL);
lst = NULL;
while (map)
{
tmp.data = ((t_list*)map->value)->content;
tmp.data_size = ((t_list*)map->value)->content_size;
if (!ft_datacmp(value, &tmp))
{
add = (t_list*)map->key;
add = ft_lstnew(add->content, add->content_size);
ft_lstpush(&lst, add);
}
map = map->next;
}
return (lst);
}