-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strnew.c
28 lines (24 loc) · 1.17 KB
/
ft_strnew.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strnew.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mwilliam <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/03 12:17:44 by mwilliam #+# #+# */
/* Updated: 2016/12/03 12:17:46 by mwilliam ### ########.fr */
/* */
/* ************************************************************************** */
/*
** Allocates with malloc and returns a "fresh" string ending with '\0'
** Each character is initialized at '\0'
*/
#include "libft.h"
char *ft_strnew(size_t size)
{
char *fresh;
if (!(fresh = (char *)malloc(sizeof(char) * size + 1)))
return (NULL);
ft_bzero(fresh, size + 1);
return (fresh);
}