diff options
Diffstat (limited to 'src/dstr/ft_dstrnew.c')
| -rw-r--r-- | src/dstr/ft_dstrnew.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/dstr/ft_dstrnew.c b/src/dstr/ft_dstrnew.c index 8ae4a64..fe9ce46 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/06/09 17:35:14 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -21,12 +21,12 @@ t_ftdstr *ft_dstrnew(char *from) { - t_ftdstr *dstr; + char *clone; + t_ftdstr *ret; - if ((dstr = (t_ftdstr*)malloc(sizeof(t_ftdstr))) == NULL || - (dstr->str = ft_strdup(from)) == NULL) + if ((clone = ft_strdup(from)) == NULL) return (NULL); - dstr->length = ft_strlen(from); - dstr->capacity = dstr->length + 1; - return (dstr); + if ((ret = ft_dstrwrap(clone)) == NULL) + free(clone); + return (ret); } |
