-
Notifications
You must be signed in to change notification settings - Fork 0
/
gl_functions.c
66 lines (56 loc) · 1.71 KB
/
gl_functions.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#ifndef GL_FUNCTION
#define GL_FUNCTION
#include <stdlib.h>
#include <stdio.h>
/*dynamic allocation of 2d double variables*/
double** Make2DDoubleArray(int arraySizeX, int arraySizeY, char info[])
{
int i;
double** theArray;
if ((theArray = (double**) calloc(arraySizeX,sizeof(double*)))== NULL) {
printf("error in allocating pointer arrays of %s\n",info);
}
for (i=0; i<arraySizeX; i++)
{
if ((*(theArray+i) = (double*) calloc(arraySizeY,sizeof(double)))== NULL) {
printf("error in allocating arrays of %s\n",info);
};
//for (j=0; j<arraySizeY; j++) theArray[i][j]=0.0;
}
return theArray;
}
/*dynamic allocation of 2d integer variables*/
int** Make2DIntArray(int arraySizeX, int arraySizeY,char info[])
{
int i;
int** theArray;
if ((theArray = (int**) calloc(arraySizeX,sizeof(int*)))==NULL) {
printf("error in allocating pointer arrays of %s\n",info);
};
for (i=0; i<arraySizeX; i++)
{
if ((*(theArray+i) = (int*) calloc(arraySizeY,sizeof(int)))==NULL) {
printf("error in allocating arrays of %s\n",info);
}
//for (j=0; j<arraySizeY; j++) theArray[i][j]=0;
}
return theArray;
}
/*dynamic allocation of 2d float variables*/
float** Make2DFloatArray(int arraySizeX, int arraySizeY, char info[])
{
int i;
float** theArray;
if ((theArray = (float**) calloc(arraySizeX,sizeof(float*)))== NULL) {
printf("error in allocating pointer arrays of %s\n",info);
}
for (i=0; i<arraySizeX; i++)
{
if ((*(theArray+i) = (float*) calloc(arraySizeY,sizeof(float)))== NULL) {
printf("error in allocating arrays of %s\n",info);
};
//for (j=0; j<arraySizeY; j++) theArray[i][j]=0.0;
}
return theArray;
}
#endif