NAME

cxDataObjNew - create a new data object of an arbitrary type

C SPECIFICATION

#include <cx/DataOps.h>

void *cxDataObjNew( char *typename )

FORTRAN SPECIFICATION

integer function cxDataObjNew( typename )
character * (*) typename

PARAMETERS

typename
Data type name.

FUNCTION RETURN VALUE

Returns a pointer to a new data object of the given type.

DESCRIPTION

cxDataObjNew is used to create a new reference-counted data object. It is used by automatically generated routines for allocating user-defined data types, and you must use it if you write your own data allocation routine.

Only the base structure is created by cxDataObjNew. For example, given a type name of "cxLattice", cxDataObjNew will return a pointer to a cxLattice structure. The ndim, data, dims, and coord fields will be 0 or NULL. Additional memory allocation for arrays is done with cxDataMalloc, cxDataCalloc, and cxDataRealloc. The data's reference count will be 0; the allocation routine should NOT increment the reference count.

Data structures are allocated from a shared memory arena on Silicon Graphics workstations running IRIX. This shared memory is a limited resource, so it is possible for the memory to be exhausted, causing the allocation routine to fail. If there is not enough memory to allocate the structure, a NULL pointer will be returned, and the subroutine cxDataAllocErrorGet will return TRUE. If a user-supplied allocation routine detects the out-of-memory condition after a call to cxDataObjNew, cxDataMalloc, cxDataCalloc, or cxDataRealloc, it is recommended that the allocation routine free all memory it successfully allocated and return NULL. Use cxDataFree to free regular memory, and cxDataRefDec to free any reference-counted structures.

SEE ALSO

cxDataAllocErrorGet(3E), cxDataMalloc(3E), cxDataCalloc(3E), cxDataRealloc(3E), cxDataFree(3E), cxDataRefDec(3E)
Last modified: Mon Nov 18 13:48:08 GMT 1996
[ Documentation Home ]
© The Numerical Algorithms Group Ltd, Oxford UK. 1996