some printf leaks
This commit is contained in:
parent
d5d39e5653
commit
ae6401ca05
21 changed files with 73 additions and 57 deletions
|
|
@ -1,3 +1,15 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* btree.h :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2016/11/16 11:13:15 by jhalford #+# #+# */
|
||||||
|
/* Updated: 2016/11/16 11:14:02 by jhalford ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#ifndef BTREE_H
|
#ifndef BTREE_H
|
||||||
# define BTREE_H
|
# define BTREE_H
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/08/19 12:06:15 by jhalford #+# #+# */
|
/* Created: 2016/08/19 12:06:15 by jhalford #+# #+# */
|
||||||
/* Updated: 2016/08/23 17:49:17 by jhalford ### ########.fr */
|
/* Updated: 2016/11/16 11:14:28 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/14 18:06:24 by jhalford #+# #+# */
|
/* Created: 2016/11/14 18:06:24 by jhalford #+# #+# */
|
||||||
/* Updated: 2016/11/14 18:26:32 by jhalford ### ########.fr */
|
/* Updated: 2016/11/16 11:24:32 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -15,9 +15,12 @@
|
||||||
static void print_offset(int offset)
|
static void print_offset(int offset)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < offset; ++i)
|
|
||||||
|
i = 0;
|
||||||
|
while (i < offset)
|
||||||
{
|
{
|
||||||
ft_putstr(" ");
|
ft_putstr(" ");
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -26,14 +29,12 @@ void btree_print(t_btree* tree, void (*printer)(t_btree *tree))
|
||||||
static int offset = 0;
|
static int offset = 0;
|
||||||
|
|
||||||
print_offset(offset);
|
print_offset(offset);
|
||||||
|
|
||||||
if (tree == NULL)
|
if (tree == NULL)
|
||||||
{
|
{
|
||||||
ft_putendl("-");
|
ft_putendl("-");
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
(*printer)(tree);
|
(*printer)(tree);
|
||||||
|
|
||||||
offset += 3;
|
offset += 3;
|
||||||
btree_print(tree->right, printer);
|
btree_print(tree->right, printer);
|
||||||
btree_print(tree->left, printer);
|
btree_print(tree->left, printer);
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/14 17:55:40 by jhalford #+# #+# */
|
/* Created: 2016/11/14 17:55:40 by jhalford #+# #+# */
|
||||||
/* Updated: 2016/11/14 17:57:46 by jhalford ### ########.fr */
|
/* Updated: 2016/11/16 11:15:40 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
3
libft/src/env/ft_getenv.c
vendored
3
libft/src/env/ft_getenv.c
vendored
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/10 14:30:00 by jhalford #+# #+# */
|
/* Created: 2016/11/10 14:30:00 by jhalford #+# #+# */
|
||||||
/* Updated: 2016/11/10 14:30:27 by jhalford ### ########.fr */
|
/* Updated: 2016/11/16 11:24:52 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -18,7 +18,6 @@ char *ft_getenv(char **env, char *key)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
while (*env)
|
while (*env)
|
||||||
{
|
{
|
||||||
/* ft_printf("%s\n", env[i]); */
|
|
||||||
if (ft_strcmp(*env, key) == '=')
|
if (ft_strcmp(*env, key) == '=')
|
||||||
return (*env + ft_strlen(key) + 1);
|
return (*env + ft_strlen(key) + 1);
|
||||||
env++;
|
env++;
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/07 13:31:48 by jhalford #+# #+# */
|
/* Created: 2016/11/07 13:31:48 by jhalford #+# #+# */
|
||||||
/* Updated: 2016/11/10 12:59:25 by jhalford ### ########.fr */
|
/* Updated: 2016/11/16 18:30:20 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -33,9 +33,9 @@ char *ft_unsigned_conversion(t_fmt *fmt, va_list ap)
|
||||||
while (fmt->conversion != g_convs[i].id)
|
while (fmt->conversion != g_convs[i].id)
|
||||||
i++;
|
i++;
|
||||||
if (!*fmt->modifier
|
if (!*fmt->modifier
|
||||||
|| ft_strcmp(fmt->modifier, "hh") == 0
|
|| ft_strequ(fmt->modifier, "hh")
|
||||||
|| ft_strcmp(fmt->modifier, "h") == 0
|
|| ft_strequ(fmt->modifier, "h")
|
||||||
|| ft_strcmp(fmt->modifier, "z") == 0)
|
|| ft_strequ(fmt->modifier, "z"))
|
||||||
{
|
{
|
||||||
uiarg = va_arg(ap, int);
|
uiarg = va_arg(ap, int);
|
||||||
return (ft_uitoa_base(uiarg, g_convs[i].base));
|
return (ft_uitoa_base(uiarg, g_convs[i].base));
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/07 16:53:07 by jhalford #+# #+# */
|
/* Created: 2016/11/07 16:53:07 by jhalford #+# #+# */
|
||||||
/* Updated: 2016/11/10 13:02:07 by jhalford ### ########.fr */
|
/* Updated: 2016/11/16 11:15:55 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -46,7 +46,6 @@ static void ft_fmt_validate_flag_conv(t_fmt *fmt)
|
||||||
if (!ft_strchr(g_convs[i].allowed_flags, flag))
|
if (!ft_strchr(g_convs[i].allowed_flags, flag))
|
||||||
{
|
{
|
||||||
ft_fmt_error_flag_conv(flag, fmt->conversion);
|
ft_fmt_error_flag_conv(flag, fmt->conversion);
|
||||||
/* ft_printf("allowed flags:%s\n", g_convs[i].allowed_flags); */
|
|
||||||
if (flag == '#')
|
if (flag == '#')
|
||||||
*flag_ptr = '.';
|
*flag_ptr = '.';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/07 13:33:27 by jhalford #+# #+# */
|
/* Created: 2016/11/07 13:33:27 by jhalford #+# #+# */
|
||||||
/* Updated: 2016/11/16 10:58:04 by jhalford ### ########.fr */
|
/* Updated: 2016/11/16 18:30:10 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -30,7 +30,7 @@ int ft_printf(const char *format, ...)
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
return(ft_vdprintf(0, format, ap));
|
return (ft_vdprintf(1, format, ap));
|
||||||
}
|
}
|
||||||
|
|
||||||
int ft_dprintf(int fd, const char *format, ...)
|
int ft_dprintf(int fd, const char *format, ...)
|
||||||
|
|
@ -44,10 +44,11 @@ int ft_dprintf(int fd, const char *format, ...)
|
||||||
int ft_vdprintf(int fd, const char *format, va_list ap)
|
int ft_vdprintf(int fd, const char *format, va_list ap)
|
||||||
{
|
{
|
||||||
char *str;
|
char *str;
|
||||||
|
char *transform;
|
||||||
char final[1000];
|
char final[1000];
|
||||||
t_fmt *fmt;
|
t_fmt *fmt;
|
||||||
|
|
||||||
str = ft_strdup(format);
|
str = (char *)format;
|
||||||
ft_bzero(final, 1000);
|
ft_bzero(final, 1000);
|
||||||
while (*str)
|
while (*str)
|
||||||
{
|
{
|
||||||
|
|
@ -59,12 +60,16 @@ int ft_vdprintf(int fd, const char *format, va_list ap)
|
||||||
if (!fmt->valid)
|
if (!fmt->valid)
|
||||||
ft_strncat(final, &fmt->conversion, 1);
|
ft_strncat(final, &fmt->conversion, 1);
|
||||||
else
|
else
|
||||||
ft_strcat(final, ft_transform(fmt, ap));
|
{
|
||||||
|
transform = ft_transform(fmt, ap);
|
||||||
|
ft_strcat(final, transform);
|
||||||
|
free(transform);
|
||||||
|
}
|
||||||
|
free(fmt);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ft_strncat(final, str++, 1);
|
ft_strncat(final, str++, 1);
|
||||||
}
|
}
|
||||||
ft_putstr_fd(final, fd);
|
ft_putstr_fd(final, fd);
|
||||||
ft_strdel(&str);
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/07 13:33:32 by jhalford #+# #+# */
|
/* Created: 2016/11/07 13:33:32 by jhalford #+# #+# */
|
||||||
/* Updated: 2016/11/07 16:40:15 by jhalford ### ########.fr */
|
/* Updated: 2016/11/16 17:56:37 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -14,7 +14,6 @@
|
||||||
|
|
||||||
char *ft_transform(t_fmt *fmt, va_list ap)
|
char *ft_transform(t_fmt *fmt, va_list ap)
|
||||||
{
|
{
|
||||||
char *buf;
|
|
||||||
char *ret;
|
char *ret;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
|
@ -24,11 +23,7 @@ char *ft_transform(t_fmt *fmt, va_list ap)
|
||||||
fmt->conv = g_convs[i];
|
fmt->conv = g_convs[i];
|
||||||
ret = (*fmt->conv.converter)(fmt, ap);
|
ret = (*fmt->conv.converter)(fmt, ap);
|
||||||
if (fmt->width > (int)ft_strlen(ret))
|
if (fmt->width > (int)ft_strlen(ret))
|
||||||
{
|
ret = ft_realloc(ret, fmt->width + 5);
|
||||||
buf = ret;
|
|
||||||
ret = (char *)malloc(sizeof(char) * (fmt->width + 5));
|
|
||||||
ft_strcpy(ret, buf);
|
|
||||||
}
|
|
||||||
if (ft_strchr(fmt->flags, '-'))
|
if (ft_strchr(fmt->flags, '-'))
|
||||||
ft_pad_right(ret, fmt);
|
ft_pad_right(ret, fmt);
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/07 13:33:35 by jhalford #+# #+# */
|
/* Created: 2016/11/07 13:33:35 by jhalford #+# #+# */
|
||||||
/* Updated: 2016/11/07 17:22:26 by jhalford ### ########.fr */
|
/* Updated: 2016/11/16 17:46:16 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/07 13:33:45 by jhalford #+# #+# */
|
/* Created: 2016/11/07 13:33:45 by jhalford #+# #+# */
|
||||||
/* Updated: 2016/11/08 10:18:08 by jhalford ### ########.fr */
|
/* Updated: 2016/11/16 18:13:08 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -24,7 +24,7 @@ void ft_pad_left(char *str, t_fmt *fmt)
|
||||||
{
|
{
|
||||||
char sign;
|
char sign;
|
||||||
|
|
||||||
sign = '\0';
|
sign = 0;
|
||||||
if (str[0] == '-' || str[0] == '+' || str[0] == ' ')
|
if (str[0] == '-' || str[0] == '+' || str[0] == ' ')
|
||||||
{
|
{
|
||||||
sign = str[0];
|
sign = str[0];
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/07 13:33:48 by jhalford #+# #+# */
|
/* Created: 2016/11/07 13:33:48 by jhalford #+# #+# */
|
||||||
/* Updated: 2016/11/08 10:18:20 by jhalford ### ########.fr */
|
/* Updated: 2016/11/16 17:56:42 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/04 11:09:12 by jhalford #+# #+# */
|
/* Created: 2016/11/04 11:09:12 by jhalford #+# #+# */
|
||||||
/* Updated: 2016/11/14 16:55:27 by jhalford ### ########.fr */
|
/* Updated: 2016/11/16 18:23:24 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -28,6 +28,7 @@ void ft_lst_delif(
|
||||||
{
|
{
|
||||||
tmp = (*indirect);
|
tmp = (*indirect);
|
||||||
(*indirect) = (*indirect)->next;
|
(*indirect) = (*indirect)->next;
|
||||||
|
ft_printf("free'd at %p\n", tmp);
|
||||||
(*del)(tmp->content, tmp->content_size);
|
(*del)(tmp->content, tmp->content_size);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/04 11:09:30 by jhalford #+# #+# */
|
/* Created: 2016/11/04 11:09:30 by jhalford #+# #+# */
|
||||||
/* Updated: 2016/11/08 11:52:33 by jhalford ### ########.fr */
|
/* Updated: 2016/11/16 14:00:07 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/03 15:18:57 by jhalford #+# #+# */
|
/* Created: 2016/11/03 15:18:57 by jhalford #+# #+# */
|
||||||
/* Updated: 2016/11/08 13:36:19 by jhalford ### ########.fr */
|
/* Updated: 2016/11/16 18:24:38 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -14,7 +14,11 @@
|
||||||
|
|
||||||
void ft_lstdel(t_list **alst, void (*del)(void *, size_t))
|
void ft_lstdel(t_list **alst, void (*del)(void *, size_t))
|
||||||
{
|
{
|
||||||
if (alst && *alst && (*alst)->next)
|
if (alst && *alst && del)
|
||||||
|
{
|
||||||
|
ft_printf("free'd at %p\n", *alst);
|
||||||
ft_lstdel(&(*alst)->next, del);
|
ft_lstdel(&(*alst)->next, del);
|
||||||
ft_lstdelone(alst, del);
|
ft_lstdelone(alst, del);
|
||||||
|
*alst = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/03 14:57:15 by jhalford #+# #+# */
|
/* Created: 2016/11/03 14:57:15 by jhalford #+# #+# */
|
||||||
/* Updated: 2016/11/14 15:50:00 by jhalford ### ########.fr */
|
/* Updated: 2016/11/16 18:22:47 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -19,6 +19,6 @@ void ft_lstdelone(t_list **alst, void (*del)(void *, size_t))
|
||||||
if (del)
|
if (del)
|
||||||
(*del)((*alst)->content, (*alst)->content_size);
|
(*del)((*alst)->content, (*alst)->content_size);
|
||||||
free(*alst);
|
free(*alst);
|
||||||
}
|
|
||||||
*alst = NULL;
|
*alst = NULL;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,14 +6,17 @@
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/03 14:57:33 by jhalford #+# #+# */
|
/* Created: 2016/11/03 14:57:33 by jhalford #+# #+# */
|
||||||
/* Updated: 2016/11/03 14:57:33 by jhalford ### ########.fr */
|
/* Updated: 2016/11/16 12:23:13 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "libft.h"
|
#include "libft.h"
|
||||||
|
|
||||||
void ft_memdel(void **ap)
|
void ft_memdel(void **ap)
|
||||||
|
{
|
||||||
|
if (ap && *ap)
|
||||||
{
|
{
|
||||||
free(*ap);
|
free(*ap);
|
||||||
*ap = NULL;
|
*ap = NULL;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/11 17:37:53 by jhalford #+# #+# */
|
/* Created: 2016/11/11 17:37:53 by jhalford #+# #+# */
|
||||||
/* Updated: 2016/11/11 17:41:30 by jhalford ### ########.fr */
|
/* Updated: 2016/11/16 17:56:17 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -16,10 +16,8 @@ void *ft_realloc(void *data, int size)
|
||||||
{
|
{
|
||||||
void *new;
|
void *new;
|
||||||
|
|
||||||
ft_printf("realloc befor: '%s'\n", data);
|
|
||||||
new = ft_memalloc(size);
|
new = ft_memalloc(size);
|
||||||
ft_memcpy(new, data, ft_strlen(data));
|
ft_memcpy(new, data, ft_strlen(data));
|
||||||
ft_memdel(&data);
|
ft_memdel(&data);
|
||||||
ft_printf("realloc after: '%s'\n", new);
|
|
||||||
return (new);
|
return (new);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/04 11:45:07 by jhalford #+# #+# */
|
/* Created: 2016/11/04 11:45:07 by jhalford #+# #+# */
|
||||||
/* Updated: 2016/11/04 11:45:08 by jhalford ### ########.fr */
|
/* Updated: 2016/11/16 12:07:21 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/07 15:46:03 by jhalford #+# #+# */
|
/* Created: 2016/11/07 15:46:03 by jhalford #+# #+# */
|
||||||
/* Updated: 2016/11/07 15:46:11 by jhalford ### ########.fr */
|
/* Updated: 2016/11/16 17:58:02 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/03 14:58:43 by jhalford #+# #+# */
|
/* Created: 2016/11/03 14:58:43 by jhalford #+# #+# */
|
||||||
/* Updated: 2016/11/03 14:58:43 by jhalford ### ########.fr */
|
/* Updated: 2016/11/16 17:52:01 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -17,8 +17,7 @@ char *ft_strsub(char const *s, unsigned int start, size_t len)
|
||||||
char *out;
|
char *out;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
out = (char *)malloc(sizeof(char) * (len + 1));
|
if (!(out = (char *)malloc(sizeof(char) * (len + 1))))
|
||||||
if (!out)
|
|
||||||
return (NULL);
|
return (NULL);
|
||||||
i = -1;
|
i = -1;
|
||||||
while (++i < len)
|
while (++i < len)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue