-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_matrix_new.c
executable file
·35 lines (32 loc) · 1.31 KB
/
ft_matrix_new.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_matrix_new.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: akharrou <akharrou@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/03/04 15:54:03 by akharrou #+# #+# */
/* Updated: 2019/03/04 15:54:05 by akharrou ### ########.fr */
/* */
/* ************************************************************************** */
#include "../Includes/stdlib_42.h"
void **ft_matrix_new(void **matrix, size_t height, size_t width,
size_t typesize)
{
unsigned int i;
if (height > 0)
{
if (!(matrix = (void **)malloc(sizeof(void *) * (height + 1))))
{
matrix[height] = NULL;
i = 0;
while (height > i)
if (!(matrix[i++] = ft_memalloc(typesize * (width + 1))))
break ;
if (height == i)
return (matrix);
free(matrix);
}
}
return (NULL);
}