diff options
| author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-01-24 18:56:40 +0100 | 
|---|---|---|
| committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-01-24 18:56:40 +0100 | 
| commit | 7514811995c3573716008af1c6c409911ac1ea4a (patch) | |
| tree | 08e7af8ed7df36971cb06b63e81a49695963eb3d | |
| parent | cleaner frees (diff) | |
| download | 42-cub3d-7514811995c3573716008af1c6c409911ac1ea4a.tar.gz 42-cub3d-7514811995c3573716008af1c6c409911ac1ea4a.tar.bz2 42-cub3d-7514811995c3573716008af1c6c409911ac1ea4a.tar.xz 42-cub3d-7514811995c3573716008af1c6c409911ac1ea4a.tar.zst 42-cub3d-7514811995c3573716008af1c6c409911ac1ea4a.zip  | |
strdups
Diffstat (limited to '')
| -rw-r--r-- | src/ft_get_sprite_tex.c | 5 | ||||
| -rw-r--r-- | src/ft_get_tex.c | 20 | 
2 files changed, 5 insertions, 20 deletions
diff --git a/src/ft_get_sprite_tex.c b/src/ft_get_sprite_tex.c index 4cec41a..b246b5e 100644 --- a/src/ft_get_sprite_tex.c +++ b/src/ft_get_sprite_tex.c @@ -7,7 +7,6 @@ ft_get_sprite_tex(int fd, t_win *wlist)  {  	char	*line;  	char	**words; -	size_t	len;  	get_next_line(fd, &line);  	if (!(words = ft_split(line, ' '))) @@ -21,13 +20,11 @@ ft_get_sprite_tex(int fd, t_win *wlist)  		return (ft_map_error(7, wlist));  	}  	ft_memdel(wlist->clist->sprite_path); -	len = ft_strlen(*(words + 1)); -	if (!(wlist->clist->sprite_path = (char*)malloc((len + 1) * sizeof(char)))) +	if (!(wlist->clist->sprite_path = ft_strdup(*(words + 1))))  	{  		ft_free_words(words, line);  		return (-1);  	} -	ft_strlcpy(wlist->clist->sprite_path, *(words + 1), len + 1);  	ft_free_words(words, line);  	return (0);  } diff --git a/src/ft_get_tex.c b/src/ft_get_tex.c index 0e394dc..7841e1d 100644 --- a/src/ft_get_tex.c +++ b/src/ft_get_tex.c @@ -7,7 +7,6 @@ ft_get_tex_no(int fd, t_win *wlist)  {  	char	*line;  	char	**words; -	size_t	len;  	get_next_line(fd, &line);  	if (!(words = ft_split(line, ' '))) @@ -22,13 +21,11 @@ ft_get_tex_no(int fd, t_win *wlist)  		return (ft_map_error(2, wlist));  	}  	ft_memdel(wlist->clist->no_tex_path); -	len = ft_strlen(*(words + 1)); -	if (!(wlist->clist->no_tex_path = (char*)malloc((len + 1) * sizeof(char)))) +	if (!(wlist->clist->no_tex_path = ft_strdup(*(words + 1))))  	{  		ft_free_words(words, line);  		return (-1);  	} -	ft_strlcpy(wlist->clist->no_tex_path, *(words + 1), len + 1);  	ft_free_words(words, line);  	return (0);  } @@ -38,7 +35,6 @@ ft_get_tex_so(int fd, t_win *wlist)  {  	char	*line;  	char	**words; -	size_t	len;  	get_next_line(fd, &line);  	if (!(words = ft_split(line, ' '))) @@ -53,13 +49,11 @@ ft_get_tex_so(int fd, t_win *wlist)  		return (ft_map_error(3, wlist));  	}  	ft_memdel(wlist->clist->so_tex_path); -	len = ft_strlen(*(words + 1)); -	if (!(wlist->clist->so_tex_path = (char*)malloc((len + 1) * sizeof(char)))) +	if (!(wlist->clist->so_tex_path = ft_strdup(*(words + 1))))  	{  		ft_free_words(words, line);  		return (-1);  	} -	ft_strlcpy(wlist->clist->so_tex_path, *(words + 1), len + 1);  	ft_free_words(words, line);  	return (0);  } @@ -69,7 +63,6 @@ ft_get_tex_we(int fd, t_win *wlist)  {  	char	*line;  	char	**words; -	size_t	len;  	get_next_line(fd, &line);  	if (!(words = ft_split(line, ' '))) @@ -84,13 +77,11 @@ ft_get_tex_we(int fd, t_win *wlist)  		return (ft_map_error(4, wlist));  	}  	ft_memdel(wlist->clist->we_tex_path); -	len = ft_strlen(*(words + 1)); -	if (!(wlist->clist->we_tex_path = (char*)malloc((len + 1) * sizeof(char)))) +	if (!(wlist->clist->we_tex_path = ft_strdup(*(words + 1))))  	{  		ft_free_words(words, line);  		return (-1);  	} -	ft_strlcpy(wlist->clist->we_tex_path, *(words + 1), len + 1);  	ft_free_words(words, line);  	return (0);  } @@ -100,7 +91,6 @@ ft_get_tex_ea(int fd, t_win *wlist)  {  	char	*line;  	char	**words; -	size_t	len;  	get_next_line(fd, &line);  	if (!(words = ft_split(line, ' '))) @@ -115,13 +105,11 @@ ft_get_tex_ea(int fd, t_win *wlist)  		return (ft_map_error(5, wlist));  	}  	ft_memdel(wlist->clist->ea_tex_path); -	len = ft_strlen(*(words + 1)); -	if (!(wlist->clist->ea_tex_path = (char*)malloc((len + 1) * sizeof(char)))) +	if (!(wlist->clist->ea_tex_path = ft_strdup(*(words + 1))))  	{  		ft_free_words(words, line);  		return (-1);  	} -	ft_strlcpy(wlist->clist->ea_tex_path, *(words + 1), len + 1);  	ft_free_words(words, line);  	return (0);  }  | 
