#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 *cxDataMemBoundsCheck(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 cxDataMemBoundsCheck(data, description) integer data integer description
If an error is detected, the cxDataCheckAction defined by cxDataCheckingSet is called, a cxDataCheckErrorInfo structure is returned. Otherwise, a NULL is returned. It is the user's responsibility to destroy the returned error structure using cxDataCheckErrorInfoDel. The contents of the error structure are described in more detail in cxDataCheck. cxDataMemBoundsCheck calls cxDataMagicCheck before doing the memory bounds check.
The memory bounds contains information about the allocated size of the memory. The system flags an error when the memory block is smaller than required, e.g. if the dims vector of a cxLattice was allocated to hold 1 word, but the nDim value is greater than 1. However, it is not an error for the allocated memory to be larger than what is required. This allows data structures to be reduced in size or dimension easily. For example, LatToPyr converts an N-D lattice into a 1-D lattice by duplicating the lattice, then setting nDim to 1 and dims[0] to the product of the previous dimensions. The dims vector only requires 1 word, even though it was allocated to hold N words when the lattice was duplicated.