#include <cx/DataOps.h>typedef enum { cx_data_dead, cx_mem_size, cx_mem_bounds, cx_data_ok } cxDataCheckError;
typedef struct { cxDataCheckError error; void *ptr; char *msg;
} cxDataCheckErrorInfo;
cxDataCheckErrorInfo *cxDataCheck( void *data, char *description )
integer cx_data_dead integer cx_mem_size integer cx_mem_bounds integer cx_data_okparameter (cx_data_dead = 0) parameter (cx_mem_size = 1) parameter (cx_mem_bounds = 2) parameter (cx_data_ok = 3)
integer function cxDataCheck(data, description) integer data integer description
The error field of the returned structure enumerates the actual error detected. The ptr field points to the actual offending memory. The msg field contains a message that helps trace the exact location of the error. For example, the following code:
cxDataCheckErrorInfo *err; cxLattice *lat = cxLatNew( ... ); lat->nDim = -1; /* should be > 0 */ err = cxDataCheckSet( lat, "constructed the lattice" );
would return an error structure in which error is cx_ndim_range, ptr is the address of lat->nDim, and the trace message is something like this:
Number of cxLattice dimensions <= 0, in cxLattice @ 0x806dfc constructed the lattice
The trace message and ptr field are especially valuable when an error occurs in nested IRIS Explorer types, e.g. the nDim in the cxCoord in the cxLattice in the second layer of a cxPyramid.
If no error is detected, a NULL is returned.