NAME
SYNOPSIS
#include "allocf.h"
DESCRIPTION
SEE ALSO
AUTHOR

NAME

calloc4f, free4f - dynamic allocators for four dimensional arrays of floats

SYNOPSIS

#include "allocf.h"

float ****calloc4f(size_t l, size_t k, size_t j, size_t i);
void free4f(float ****d);

DESCRIPTION

These allocators create four dimensional arrays of float values.

calloc4f allocates a four dimensional array of float values. If the return value is assigned to d, then the highest index of the array is d[l-1][k-1][j-1][i-1]. terminated. d[0][0][0] is a contiguous block of l * k * j * i floats.

Each dimension array in d is terminated with a pointer to the end of the next dimension. In other words, d[lmax] points to d[lmax-1][kmax], d[lmax-1][kmax] points to d[lmax-1][kmax-1][jmax], and d[lmax-1][kmax-1][jmax] points to d[lmax-1][kmax-1][jmax-1][imax]. Also, d[lmax+1] is NULL. This facilitates array traversal with mini- mal indexing. The following loops are equivalent.

for (l = 0; l < lmax; l++)
for (k = 0; k < kmax; k++)
for (j = 0; j < jmax; j++)
for (i = 0; i < imax; i++)
use(dat[l][k][j][i]);

for (p4 = dat; p4[1]; p4++)
for (p3 = p4[0]; p3 < p4[1]; p3++)
for (p2 = p3[0]; p2 < p3[1]; p2++)
for (p = p2[0]; p < p2[1]; p++)
use(*p);

The second loop might be faster for some compilers and options.

If something goes wrong, the function generates an error message that can be retrieved with a call to err_get, and returns NULL.

free4f frees all memory associated with d, which should be a return value of malloc4f.

SEE ALSO

alloc2f (3), alloc3f (3), err_msg (3), allocfvi (1).

AUTHOR

Gordon Carrie (dev0 at this site)