diff options
Diffstat (limited to 'libft/src/dstr/ft_dstrnew.c')
| -rw-r--r-- | libft/src/dstr/ft_dstrnew.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/libft/src/dstr/ft_dstrnew.c b/libft/src/dstr/ft_dstrnew.c new file mode 100644 index 0000000..fe9ce46 --- /dev/null +++ b/libft/src/dstr/ft_dstrnew.c @@ -0,0 +1,32 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_dstrnew.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/04/03 13:54:52 by charles #+# #+# */ +/* Updated: 2020/06/09 17:35:14 by charles ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft_dstr.h" + +/* +** \brief Create a new dynamic string +** \param from Static string to create the dynamic one from +** (will be duplicated) +** \return Created dynamic string or NULL on malloc error +*/ + +t_ftdstr *ft_dstrnew(char *from) +{ + char *clone; + t_ftdstr *ret; + + if ((clone = ft_strdup(from)) == NULL) + return (NULL); + if ((ret = ft_dstrwrap(clone)) == NULL) + free(clone); + return (ret); +} |
