[Nexus-developers] C version of NXU (Utility API) routines

Akeroyd, FA (Freddie) F.A.Akeroyd at rl.ac.uk
Thu Mar 10 15:57:16 GMT 2005


I have added a header file "napiu.h" to CVS (see
http://nexus.isis.rl.ac.uk/cgi-bin/viewcvs.cgi/include/napiu.h?rev=1.1&c
ontent-type=text/vnd.viewcvs-markup) containing the C declarations for
NXU routines - I have taken as a basis the F90 implementation as
detailed at http://www.nexus.anl.gov/nexus_f90.html#NXUwriteglobals This
page mentions NXUwritehistogram and NXUreadhistogram functions, though
these are not currently implemented in NXUmodule.f90; are they still
required?

 

Though the C signature of the functions can be the same as the F90 ones
in most cases, there are a few exceptions. The C NXUwritedata cannot
follow the F90 one exactly as F90 arrays know their size and so do not
require such parameters; also F90 allows several functions for different
array types/dimensionality to be written and a general "interface" to be
defined that will map to the correct function at compile time. I have
thus added additional size, rank and type parameters to NXUwritedata and
NXUreaddata

 

A general question concerns memory allocation: should the NXU functions
allocate memory for the caller or rely on being provided with a buffer
of at least the correct size; if the latter, then should extra size
parameters be added so that buffer overruns are detected? The functions
concerned are:

 

NXUreadhistogram and NXUreaddata - allocate space for returned data or
assume this will be provided?

NXUfindgroup - allocate space for group_class output variable or assume
this will be provided?

NXUfindclass - allocate space for group_name output variable or assume
this will be provided?

NXUfindsignal - allocate space for data_name and data_dimensions output
variables or assume this will be provided?

NXUfindaxis - allocate space for data_name and data_dimensions output
variables or assume this will be provided?

 

If we were to prototype as e.g. (char** value), we could only allocate
memory if we are passed (*value == NULL) which would allows both memory
options, but does not address the buffer overrun issue.

 

Regards,

 

Freddie 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.nexusformat.org/pipermail/nexus-developers/attachments/20050310/a6836d71/attachment.html 


More information about the NeXus-developers mailing list