diff options
author | Rudy Bousset <rbousset@z2r5p6.le-101.fr> | 2020-02-02 17:05:54 +0100 |
---|---|---|
committer | Rudy Bousset <rbousset@z2r5p6.le-101.fr> | 2020-02-02 17:05:54 +0100 |
commit | 8d7f65c1c04f7124f1a34062be377fdbe721c46a (patch) | |
tree | 36ef68573148ba58843608a499504138cca3595d /libft | |
parent | Removed whitespace (diff) | |
download | 42-cub3d-8d7f65c1c04f7124f1a34062be377fdbe721c46a.tar.gz 42-cub3d-8d7f65c1c04f7124f1a34062be377fdbe721c46a.tar.bz2 42-cub3d-8d7f65c1c04f7124f1a34062be377fdbe721c46a.tar.xz 42-cub3d-8d7f65c1c04f7124f1a34062be377fdbe721c46a.tar.zst 42-cub3d-8d7f65c1c04f7124f1a34062be377fdbe721c46a.zip |
Correct ft_memdel
Diffstat (limited to 'libft')
-rw-r--r-- | libft/inc/libft.h | 2 | ||||
-rw-r--r-- | libft/src/ft_dprintf.c | 6 | ||||
-rw-r--r-- | libft/src/ft_memdel.c | 6 | ||||
-rw-r--r-- | libft/src/ft_printf.c | 6 | ||||
-rw-r--r-- | libft/src/ft_printf_flag_to_atoi.c | 2 | ||||
-rw-r--r-- | libft/src/ft_printf_get_flags.c | 2 | ||||
-rw-r--r-- | libft/src/ft_printf_get_width_nstr.c | 2 | ||||
-rw-r--r-- | libft/src/ft_printf_parts.c | 2 | ||||
-rw-r--r-- | libft/src/ft_printf_put_hex.c | 4 | ||||
-rw-r--r-- | libft/src/ft_printf_put_int.c | 4 | ||||
-rw-r--r-- | libft/src/ft_printf_put_precision.c | 2 | ||||
-rw-r--r-- | libft/src/ft_printf_put_ptr.c | 2 | ||||
-rw-r--r-- | libft/src/ft_printf_put_str.c | 2 | ||||
-rw-r--r-- | libft/src/ft_printf_put_width.c | 8 | ||||
-rw-r--r-- | libft/src/ft_printf_treat_flags.c | 2 | ||||
-rw-r--r-- | libft/src/ft_printf_use_flags.c | 2 | ||||
-rw-r--r-- | libft/src/ft_sprintf.c | 6 |
17 files changed, 30 insertions, 30 deletions
diff --git a/libft/inc/libft.h b/libft/inc/libft.h index 58dbbc2..4799121 100644 --- a/libft/inc/libft.h +++ b/libft/inc/libft.h @@ -68,7 +68,7 @@ void ft_lstiter(t_list *lst, void (*f)(void *)); void ft_kernel_panic(void); void ft_putnbr(long nb); void ft_putnbr_base(long nb, char *base); -void ft_memdel(void *ptr); +void ft_memdel(void **ptr); void *ft_memset(void *b, int c, size_t len); void *ft_memcpy(void *dst, const void *src, size_t n); void *ft_memccpy(void *dst, const void *src, diff --git a/libft/src/ft_dprintf.c b/libft/src/ft_dprintf.c index d9f69c1..a717df5 100644 --- a/libft/src/ft_dprintf.c +++ b/libft/src/ft_dprintf.c @@ -23,9 +23,9 @@ static int int ret; ret = write(fd, pflist->output, pflist->fulllen); - ft_memdel(pflist->output); - ft_memdel(pflist->fullflag); - ft_memdel(pflist); + ft_memdel((void**)&pflist->output); + ft_memdel((void**)&pflist->fullflag); + ft_memdel((void**)&pflist); return (ret); } diff --git a/libft/src/ft_memdel.c b/libft/src/ft_memdel.c index 05c2982..a15e494 100644 --- a/libft/src/ft_memdel.c +++ b/libft/src/ft_memdel.c @@ -14,8 +14,8 @@ #include <stdlib.h> void - ft_memdel(void *ptr) + ft_memdel(void **ptr) { - free(ptr); - ptr = NULL; + free(*ptr); + *ptr = NULL; } diff --git a/libft/src/ft_printf.c b/libft/src/ft_printf.c index 747f516..a37d76e 100644 --- a/libft/src/ft_printf.c +++ b/libft/src/ft_printf.c @@ -23,9 +23,9 @@ static int int ret; ret = write(1, pflist->output, pflist->fulllen); - ft_memdel(pflist->output); - ft_memdel(pflist->fullflag); - ft_memdel(pflist); + ft_memdel((void**)&pflist->output); + ft_memdel((void**)&pflist->fullflag); + ft_memdel((void**)&pflist); return (ret); } diff --git a/libft/src/ft_printf_flag_to_atoi.c b/libft/src/ft_printf_flag_to_atoi.c index f75a7f7..f6b2d8a 100644 --- a/libft/src/ft_printf_flag_to_atoi.c +++ b/libft/src/ft_printf_flag_to_atoi.c @@ -29,6 +29,6 @@ char len = ft_strlchr(str, ' '); nnstr = ft_substr(str, 0, len); nstr = ft_strjoin(nnstr, str + len + 1); - ft_memdel(nnstr); + ft_memdel((void**)&nnstr); return (nstr); } diff --git a/libft/src/ft_printf_get_flags.c b/libft/src/ft_printf_get_flags.c index 80ee47c..8dffd9a 100644 --- a/libft/src/ft_printf_get_flags.c +++ b/libft/src/ft_printf_get_flags.c @@ -36,7 +36,7 @@ char if (!(fullflag = (char*)malloc((i + 1) * sizeof(char)))) return (NULL); ft_memcpy(fullflag, nstr = ft_substr(format, pos + 1, i), i); - ft_memdel(nstr); + ft_memdel((void**)&nstr); fullflag[i] = '\0'; pflist->actconv = *(format + pos + i + 1); return (fullflag); diff --git a/libft/src/ft_printf_get_width_nstr.c b/libft/src/ft_printf_get_width_nstr.c index 15b9f98..cb1b665 100644 --- a/libft/src/ft_printf_get_width_nstr.c +++ b/libft/src/ft_printf_get_width_nstr.c @@ -31,7 +31,7 @@ int { str = ft_printf_flag_to_atoi(pflist->fullflag); ret = ft_atoi(str); - ft_memdel(str); + ft_memdel((void**)&str); } else { diff --git a/libft/src/ft_printf_parts.c b/libft/src/ft_printf_parts.c index 55a48dd..8c83936 100644 --- a/libft/src/ft_printf_parts.c +++ b/libft/src/ft_printf_parts.c @@ -37,7 +37,7 @@ int int ret; ft_printf_cat_output(nstr = ft_substr(format, start, len), len, pflist); - ft_memdel(nstr); + ft_memdel((void**)&nstr); ret = 0; return (ret); } diff --git a/libft/src/ft_printf_put_hex.c b/libft/src/ft_printf_put_hex.c index bbf9821..f204bf1 100644 --- a/libft/src/ft_printf_put_hex.c +++ b/libft/src/ft_printf_put_hex.c @@ -55,7 +55,7 @@ void { str = ft_uitoa_base(x, FT_MIN_HEX_BASE); ft_printf_cat_output(str, ft_strlen(str), pflist); - ft_memdel(str); + ft_memdel((void**)&str); } ft_printf_put_width_post(pflist); } @@ -80,7 +80,7 @@ void { str = ft_uitoa_base(x, FT_MAJ_HEX_BASE); ft_printf_cat_output(str, ft_strlen(str), pflist); - ft_memdel(str); + ft_memdel((void**)&str); } ft_printf_put_width_post(pflist); } diff --git a/libft/src/ft_printf_put_int.c b/libft/src/ft_printf_put_int.c index ddf06b7..6aaa49f 100644 --- a/libft/src/ft_printf_put_int.c +++ b/libft/src/ft_printf_put_int.c @@ -87,7 +87,7 @@ void { str = ft_itoa(d); ft_printf_cat_output(str, ft_strlen(str), pflist); - ft_memdel(str); + ft_memdel((void**)&str); } ft_printf_put_width_post(pflist); } @@ -109,7 +109,7 @@ void { str = ft_uitoa(d); ft_printf_cat_output(str, ft_strlen(str), pflist); - ft_memdel(str); + ft_memdel((void**)&str); } ft_printf_put_width_post(pflist); } diff --git a/libft/src/ft_printf_put_precision.c b/libft/src/ft_printf_put_precision.c index 7898102..cc237fa 100644 --- a/libft/src/ft_printf_put_precision.c +++ b/libft/src/ft_printf_put_precision.c @@ -61,7 +61,7 @@ int str = ft_memset(str, '0', len); *(str + len) = '\0'; ft_printf_cat_output(str, ft_strlen(str), pflist); - ft_memdel(str); + ft_memdel((void**)&str); } return (0); } diff --git a/libft/src/ft_printf_put_ptr.c b/libft/src/ft_printf_put_ptr.c index 409847d..9ee7636 100644 --- a/libft/src/ft_printf_put_ptr.c +++ b/libft/src/ft_printf_put_ptr.c @@ -37,7 +37,7 @@ void { str = ft_uitoa_base(p, FT_MIN_HEX_BASE); ft_printf_cat_output(str, ft_strlen(str), pflist); - ft_memdel(str); + ft_memdel((void**)&str); } ft_printf_put_width_post(pflist); } diff --git a/libft/src/ft_printf_put_str.c b/libft/src/ft_printf_put_str.c index a11128b..dcb732c 100644 --- a/libft/src/ft_printf_put_str.c +++ b/libft/src/ft_printf_put_str.c @@ -32,7 +32,7 @@ void { ft_printf_cat_output(nstr = ft_substr(str, 0, pflist->putlen), pflist->putlen, pflist); - ft_memdel(nstr); + ft_memdel((void**)&nstr); } else ft_printf_cat_output(str, pflist->putlen, pflist); diff --git a/libft/src/ft_printf_put_width.c b/libft/src/ft_printf_put_width.c index 30ae97f..d201e82 100644 --- a/libft/src/ft_printf_put_width.c +++ b/libft/src/ft_printf_put_width.c @@ -61,7 +61,7 @@ void str = ft_memset(str, ' ', ft_printf_get_len(pflist)); *(str + ft_printf_get_len(pflist)) = '\0'; ft_printf_cat_output(str, ft_strlen(str), pflist); - ft_memdel(str); + ft_memdel((void**)&str); } else if (pflist->conv == 's' && pflist->width - pflist->putlen > 0 && !pflist->isreverse) @@ -71,7 +71,7 @@ void str = ft_memset(str, ' ', ft_printf_get_len(pflist)); *(str + ft_printf_get_len(pflist)) = '\0'; ft_printf_cat_output(str, ft_strlen(str), pflist); - ft_memdel(str); + ft_memdel((void**)&str); } } @@ -89,7 +89,7 @@ void str = ft_memset(str, ' ', ft_printf_get_len(pflist)); *(str + ft_printf_get_len(pflist)) = '\0'; ft_printf_cat_output(str, ft_strlen(str), pflist); - ft_memdel(str); + ft_memdel((void**)&str); } else if (pflist->conv == 's' && pflist->width - pflist->putlen > 0 && pflist->isreverse) @@ -100,6 +100,6 @@ void str = ft_memset(str, ' ', ft_printf_get_len(pflist)); *(str + ft_printf_get_len(pflist)) = '\0'; ft_printf_cat_output(str, ft_strlen(str), pflist); - ft_memdel(str); + ft_memdel((void**)&str); } } diff --git a/libft/src/ft_printf_treat_flags.c b/libft/src/ft_printf_treat_flags.c index cb60c19..8beebca 100644 --- a/libft/src/ft_printf_treat_flags.c +++ b/libft/src/ft_printf_treat_flags.c @@ -30,7 +30,7 @@ static int nstr_ptr = nstr; nstr = ft_printf_get_width_nstr(nstr, pflist); ret = ft_printf_fetch_width(arg, nstr, pflist); - ft_memdel(nstr_ptr); + ft_memdel((void**)&nstr_ptr); (ret < 0) ? (pflist->isreverse = 1) : 0; (ret < 0) ? (ret = -ret) : 0; return (ret); diff --git a/libft/src/ft_printf_use_flags.c b/libft/src/ft_printf_use_flags.c index 7b1299e..4646bc6 100644 --- a/libft/src/ft_printf_use_flags.c +++ b/libft/src/ft_printf_use_flags.c @@ -29,7 +29,7 @@ static void va_list arg, t_printflist *pflist) { - ft_memdel(pflist->fullflag); + ft_memdel((void**)&pflist->fullflag); pflist->fullflag = ft_printf_get_flags(format, pos, pflist); ft_printf_treat_flags(arg, pflist); ft_printf_process(format + pos, arg, pflist); diff --git a/libft/src/ft_sprintf.c b/libft/src/ft_sprintf.c index 0cf5dc2..7cf0204 100644 --- a/libft/src/ft_sprintf.c +++ b/libft/src/ft_sprintf.c @@ -24,9 +24,9 @@ static int ft_strlcpy(str, pflist->output, pflist->fulllen + 1); ret = pflist->fulllen; - ft_memdel(pflist->output); - ft_memdel(pflist->fullflag); - ft_memdel(pflist); + ft_memdel((void**)&pflist->output); + ft_memdel((void**)&pflist->fullflag); + ft_memdel((void**)&pflist); return (ret); } |