calloc
This commit is contained in:
@@ -8,7 +8,7 @@
|
|||||||
unsigned short int **creatArea2D(const unsigned int N)
|
unsigned short int **creatArea2D(const unsigned int N)
|
||||||
{
|
{
|
||||||
unsigned short int **tab2d;
|
unsigned short int **tab2d;
|
||||||
tab2d = malloc(sizeof(unsigned short int* ) * N);
|
tab2d = calloc(N, sizeof(unsigned short int* ));
|
||||||
if (tab2d == NULL)
|
if (tab2d == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -18,7 +18,7 @@ unsigned short int **creatArea2D(const unsigned int N)
|
|||||||
int i;
|
int i;
|
||||||
for (i = 0; i < N && !fail; ++i)
|
for (i = 0; i < N && !fail; ++i)
|
||||||
{
|
{
|
||||||
tab2d[i] = malloc(sizeof(unsigned short int) * N);
|
tab2d[i] = calloc(N, sizeof(unsigned short int));
|
||||||
if (tab2d[i] == NULL)
|
if (tab2d[i] == NULL)
|
||||||
{
|
{
|
||||||
fail = true;
|
fail = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user