aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_save_to_bmp.c
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-03-04 16:53:15 +0100
committerJozanLeClerc <bousset.rudy@gmail.com>2020-03-04 16:53:15 +0100
commit83d542420c87fc78ba8b3cbc0af3641e4fa91e52 (patch)
tree4e95645f19902874bf4a3dd18fa4b2fb370bbdb8 /src/ft_save_to_bmp.c
parentcool sprintf (diff)
download42-cub3d-83d542420c87fc78ba8b3cbc0af3641e4fa91e52.tar.gz
42-cub3d-83d542420c87fc78ba8b3cbc0af3641e4fa91e52.tar.bz2
42-cub3d-83d542420c87fc78ba8b3cbc0af3641e4fa91e52.tar.xz
42-cub3d-83d542420c87fc78ba8b3cbc0af3641e4fa91e52.tar.zst
42-cub3d-83d542420c87fc78ba8b3cbc0af3641e4fa91e52.zip
Commit
Diffstat (limited to 'src/ft_save_to_bmp.c')
-rw-r--r--src/ft_save_to_bmp.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/ft_save_to_bmp.c b/src/ft_save_to_bmp.c
index 5d66dd2..06554ca 100644
--- a/src/ft_save_to_bmp.c
+++ b/src/ft_save_to_bmp.c
@@ -21,10 +21,20 @@ static char
{
char *str;
- if (!(str = (char*)malloc((ft_strlen(ft_strrchr(ml->filename), '/')
- + 1) * sizeof(char))))
- return (NULL);
- ft_sprintf(str, "%s", ft_strrchr(ml->filename));
+ if (ft_strrchr(ml->filename, '/'))
+ {
+ if (!(str = (char*)malloc((ft_strlen(ft_strrchr(ml->filename), '/')
+ + 1) * sizeof(char))))
+ return (NULL);
+ ft_sprintf(str, "%s", ft_strrchr(ml->filename));
+ }
+ else
+ {
+ if (!(str = (char*)malloc((ft_strlen(ml->filename)
+ + 1)* sizeof(char))))
+ return (NULL);
+ ft_sprintf(str, "%s", ft_strrchr(ml->filename));
+ }
}
static int8_t