-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_calloc.c
34 lines (31 loc) · 1.33 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_calloc.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: amennad <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/04/07 08:55:44 by amennad #+# #+# */
/* Updated: 2023/04/08 12:25:12 by amennad ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
#include <stdlib.h>
/**
* @brief
*
* @param count : nb d'éléments consécutifs à réserver dans le bloc de mémoire
* @param size : fixer la taille (en nombre d'octets) d'un élément
* @return void*
*/
void *ft_calloc(size_t count, size_t size)
{
size_t *element;
if (size == SIZE_MAX)
count = 1;
element = (void *) malloc(count * size);
if (!element)
return (NULL);
ft_bzero(element, count * size);
return ((void *) element);
}