Go to the documentation of this file.
14 short *x_ptr = (
short*) malloc(nz * ny * nx *
sizeof(
short));
16 fprintf(
stderr,
"-E- %s line %d: Memory allocation of data block failed.n", __FILE__, __LINE__);
19 short **y_ptr = (
short**) malloc(nz * ny *
sizeof(
short*));
21 fprintf(
stderr,
"-E- %s line %d: Memory allocation of y array failed.n", __FILE__, __LINE__);
24 short ***z_ptr = (
short***) malloc(nz *
sizeof(
short**));
26 fprintf(
stderr,
"-E- %s line %d: Memory allocation of z array failed.n", __FILE__, __LINE__);
29 for(
size_t z=0; z<nz; z++) {
30 for(
size_t y=0;
y<ny;
y++) {
46 int *x_ptr = (
int*) malloc(nz * ny * nx *
sizeof(
int));
48 fprintf(
stderr,
"-E- %s line %d: Memory allocation of data block failed.n", __FILE__, __LINE__);
51 int **y_ptr = (
int**) malloc(nz * ny *
sizeof(
int*));
53 fprintf(
stderr,
"-E- %s line %d: Memory allocation of y array failed.n", __FILE__, __LINE__);
56 int ***z_ptr = (
int***) malloc(nz *
sizeof(
int**));
58 fprintf(
stderr,
"-E- %s line %d: Memory allocation of z array failed.n", __FILE__, __LINE__);
61 for(
size_t z=0; z<nz; z++) {
62 for(
size_t y=0;
y<ny;
y++) {
78 float *x_ptr = (
float*) malloc(nz * ny * nx *
sizeof(
float));
80 fprintf(
stderr,
"-E- %s line %d: Memory allocation of data block failed.n", __FILE__, __LINE__);
83 float **y_ptr = (
float**) malloc(nz * ny *
sizeof(
float*));
85 fprintf(
stderr,
"-E- %s line %d: Memory allocation of y array failed.n", __FILE__, __LINE__);
88 float ***z_ptr = (
float***) malloc(nz *
sizeof(
float**));
90 fprintf(
stderr,
"-E- %s line %d: Memory allocation of z array failed.n", __FILE__, __LINE__);
93 for(
size_t z=0; z<nz; z++) {
94 for(
size_t y=0;
y<ny;
y++) {
110 double *x_ptr = (
double*) malloc(nz * ny * nx *
sizeof(
double));
112 fprintf(
stderr,
"-E- %s line %d: Memory allocation of data block failed.n", __FILE__, __LINE__);
115 double **y_ptr = (
double**) malloc(nz * ny *
sizeof(
double*));
117 fprintf(
stderr,
"-E- %s line %d: Memory allocation of y array failed.n", __FILE__, __LINE__);
120 double ***z_ptr = (
double***) malloc(nz *
sizeof(
double**));
122 fprintf(
stderr,
"-E- %s line %d: Memory allocation of z array failed.n", __FILE__, __LINE__);
125 for(
size_t z=0; z<nz; z++) {
126 for(
size_t y=0;
y<ny;
y++) {
Utility functions for allocating and freeing three-dimensional arrays of various types.
void free3d_int(int ***p)
Free a three-dimensional array created by allocate3d_int.
int *** allocate3d_int(size_t nz, size_t ny, size_t nx)
Allocate a three-dimensional array of type int of a given size.
short *** allocate3d_short(size_t nz, size_t ny, size_t nx)
Allocate a three-dimensional array of type short of a given size.
void free3d_short(short ***p)
Free a three-dimensional array created by allocate3d_short.
float *** allocate3d_float(size_t nz, size_t ny, size_t nx)
Allocate a three-dimensional array of type float of a given size.
void free3d_float(float ***p)
Free a three-dimensional array created by allocate3d_float.
void free3d_double(double ***p)
Free a three-dimensional array created by allocate3d_double.
double *** allocate3d_double(size_t nz, size_t ny, size_t nx)
Allocate a three-dimensional array of type double of a given size.