aboutsummaryrefslogtreecommitdiff
path: root/ft_strnew.c
diff options
context:
space:
mode:
Diffstat (limited to 'ft_strnew.c')
-rw-r--r--ft_strnew.c14
1 files changed, 3 insertions, 11 deletions
diff --git a/ft_strnew.c b/ft_strnew.c
index 4274d5d..1bca6d5 100644
--- a/ft_strnew.c
+++ b/ft_strnew.c
@@ -6,21 +6,13 @@
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/10/07 10:17:34 by cacharle #+# #+# */
-/* Updated: 2019/10/07 10:17:59 by cacharle ### ########.fr */
+/* Updated: 2019/11/20 03:16:14 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
-#include <stdlib.h>
-#include <string.h>
+#include "libft.h"
char *ft_strnew(size_t size)
{
- char *str;
-
- if ((str = (char*)malloc(sizeof(char) * (size + 1))) == NULL)
- return (NULL);
- str[size] = '\0';
- while (size-- > 0)
- str[size] = '\0';
- return (str);
+ return ((char*)ft_calloc(size + 1, sizeof(char)));
}