aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRudy Bousset <rbousset@z2r5p2.le-101.fr>2020-01-27 18:21:13 +0100
committerRudy Bousset <rbousset@z2r5p2.le-101.fr>2020-01-27 18:21:13 +0100
commitf65938d1d6e57f0658035b34467724be2af6ae4d (patch)
treeb17e381f9df024f7b180c8876f98f713a15dc0f5
parentquick commit (diff)
download42-cub3d-f65938d1d6e57f0658035b34467724be2af6ae4d.tar.gz
42-cub3d-f65938d1d6e57f0658035b34467724be2af6ae4d.tar.bz2
42-cub3d-f65938d1d6e57f0658035b34467724be2af6ae4d.tar.xz
42-cub3d-f65938d1d6e57f0658035b34467724be2af6ae4d.tar.zst
42-cub3d-f65938d1d6e57f0658035b34467724be2af6ae4d.zip
in progress
Diffstat (limited to '')
-rw-r--r--Makefile2
-rw-r--r--src/ft_get_map.c18
2 files changed, 12 insertions, 8 deletions
diff --git a/Makefile b/Makefile
index 0b45fb9..4814d68 100644
--- a/Makefile
+++ b/Makefile
@@ -50,7 +50,7 @@ ifdef ASAN
CFLAGS += ${FSANITIZE}
endif
#------------------------------------------------------------------------------#
-DEBUG = -g3
+DEBUG = -glldb
FSANITIZE = -fsanitize=address
#------------------------------------------------------------------------------#
ifeq (${OS}, Darwin)
diff --git a/src/ft_get_map.c b/src/ft_get_map.c
index 1c672e6..a8a6fe0 100644
--- a/src/ft_get_map.c
+++ b/src/ft_get_map.c
@@ -9,17 +9,20 @@
/* } */
static int
-ft_linecpy(char *line, char *mapL)
+ft_linecpy(char *line, char *mapL, size_t start)
{
size_t i;
+ size_t j;
i = 0;
+ j = start;
while (i < ft_strlen(line))
{
- mapL[i] = line[i];
+ mapL[j] = line[i];
i += 2;
+ j++;
}
- mapL[i + 1] = '\n';
+ mapL[j + 1] = '\n';
return (0);
}
@@ -47,7 +50,7 @@ ft_get_map(int fd, t_win *wlist)
char *line;
char *mapL;
- /* ft_free_words(wlist->clist->map, NULL); */
+ ft_free_words(wlist->clist->map, NULL);
/* if (!(wlist->clist->map = (char**)malloc(40 * sizeof(char*)))) */
/* return (-1); */
if (get_next_line(fd, &line) > 0)
@@ -55,7 +58,8 @@ ft_get_map(int fd, t_win *wlist)
len = ft_strlen(line);
ft_check_err(line, len, wlist);
if (!(mapL = (char*)malloc((len + 1) * sizeof(char))))
- ft_linecpy(line, mapL);
+ return (-1);
+ ft_linecpy(line, mapL, 0);
ft_memdel(line);
}
else
@@ -65,11 +69,11 @@ ft_get_map(int fd, t_win *wlist)
{
ft_check_err(line, len, wlist);
mapL = (char*)ft_nrealloc(mapL, ((len + 1) * i) * sizeof(char), (((len + 1) * i) + ft_strlen(line) + 1) * sizeof(char));
- ft_linecpy(line, mapL);
+ ft_linecpy(line, mapL, (len + 1) * i);
ft_memdel(line);
i++;
}
- mapL[(i * (len + 1)) + 1] = '\0';
+ mapL[(i * (len + 1)) - 1] = '\0';
ft_printf("mapL [%s]\n", mapL);
wlist->clist->map = ft_split(mapL, '\n');
ft_memdel(mapL);