File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #include "main.h"
2+ #include <stdio.h>
3+ #include <stdlib.h>
4+ /**
5+ * _calloc - calloc function
6+ * @nmemb: number of elements
7+ * @size: size of bytes
8+ * Return: pointer or void
9+ */
10+ void * _calloc (unsigned int nmemb , unsigned int size )
11+ {
12+ char * t ;
13+ unsigned int i ;
14+
15+ if (nmemb == 0 || size == 0 )
16+ return (NULL );
17+ t = malloc (nmemb * size );
18+ if (t == NULL )
19+ return (NULL );
20+ for (i = 0 ; i < nmemb * size ; i ++ )
21+ t [i ] = 0 ;
22+
23+ return (t );
24+ }
Original file line number Diff line number Diff line change @@ -304,6 +304,11 @@ void *malloc_checked(unsigned int b);
304304
305305char * string_nconcat (char * s1 , char * s2 , unsigned int n );
306306
307+ /**
308+ * _calloc - allocates memory for array using malloc
309+ */
310+
311+ void * _calloc (unsigned int nmemb , unsigned int size );
307312
308313#endif
309314
You can’t perform that action at this time.
0 commit comments