-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_memalloc.c
More file actions
42 lines (38 loc) · 1.38 KB
/
Copy pathft_memalloc.c
File metadata and controls
42 lines (38 loc) · 1.38 KB
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
39
40
41
42
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memalloc.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: vinguyen <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/10/10 04:56:07 by vinguyen #+# #+# */
/* Updated: 2019/10/10 04:56:18 by vinguyen ### ########.fr */
/* */
/* ************************************************************************** */
/*
** Allocates (with malloc(3)) and returns a “fresh” memory area.
** The memory allocated is initialized to 0. If the allocation fails,
** the function returns NULL
** Return: allocated memory area
*/
#include "libft.h"
void *ft_memalloc(size_t size)
{
unsigned char *output;
size_t i;
if (!size || size >= ULONG_MAX)
return (NULL);
output = (unsigned char*)malloc((size));
i = 0;
if (!output)
return (NULL);
else
{
while (i < (size))
{
output[i] = 0;
i++;
}
}
return (output);
}