-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathft_calloc.c
36 lines (32 loc) · 1.38 KB
/
ft_calloc.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_calloc.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apuchill <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/01/27 18:07:59 by apuchill #+# #+# */
/* Updated: 2020/02/19 14:02:46 by apuchill ### ########.fr */
/* */
/* ************************************************************************** */
/*
** LIBRARY: <stdlib.h>
** SYNOPSIS: memory allocation
**
** DESCRIPTION:
** The calloc() function contiguously allocates enough space for count
** objects that are size bytes of memory each and returns a pointer to the
** allocated memory. The allocated memory is filled with bytes of value
** zero.
*/
#include "libft.h"
void *ft_calloc(size_t count, size_t size)
{
size_t tot_size;
void *dst;
tot_size = size * count;
if (!(dst = malloc(tot_size)))
return (0);
ft_memset(dst, 0, tot_size);
return (dst);
}