diff options
Diffstat (limited to 'src/dstr/ft_dstrnew.c')
| -rw-r--r-- | src/dstr/ft_dstrnew.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/dstr/ft_dstrnew.c b/src/dstr/ft_dstrnew.c index 8ae4a64..c280dd1 100644 --- a/src/dstr/ft_dstrnew.c +++ b/src/dstr/ft_dstrnew.c @@ -6,7 +6,7 @@ /* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/03 13:54:52 by charles #+# #+# */ -/* Updated: 2020/04/04 19:50:38 by charles ### ########.fr */ +/* Updated: 2020/05/09 12:57:17 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -23,9 +23,13 @@ t_ftdstr *ft_dstrnew(char *from) { t_ftdstr *dstr; + dstr = NULL; if ((dstr = (t_ftdstr*)malloc(sizeof(t_ftdstr))) == NULL || (dstr->str = ft_strdup(from)) == NULL) + { + free(dstr); return (NULL); + } dstr->length = ft_strlen(from); dstr->capacity = dstr->length + 1; return (dstr); |
