-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_memalloc.c
executable file
·38 lines (34 loc) · 1.21 KB
/
ft_memalloc.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
29
30
31
32
33
34
35
36
37
38
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memalloc.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ngouy <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2014/11/06 12:29:00 by ngouy #+# #+# */
/* Updated: 2015/11/04 16:17:55 by ngouy ### ########.fr */
/* */
/* ************************************************************************** */
/*
** allocate and return a part of memory of a certain size
*/
#include "libft.h"
void *ft_memalloc(size_t size)
{
void *ret;
char *tb;
size_t i;
i = 0;
if (size == 0)
return (NULL);
ret = malloc(sizeof(char) * size);
tb = (char *)ret;
if (!ret)
return (NULL);
while (i < size)
{
tb[i] = '\0';
i++;
}
return (ret);
}