Ticket #1 (closed task: invalid)
C Version of NXU utility routines
| Reported by: | Freddie Akeroyd | Owned by: | Freddie Akeroyd |
|---|---|---|---|
| Priority: | minor | Milestone: | 4.3.0 |
| Component: | applications | Version: | 4.2.0 |
| Keywords: | Cc: |
Description
A C version of the FORTRAN 90 NXU* routines needs to be implemented
Change History
comment:2 Changed 5 years ago by Freddie Akeroyd
I have added a header file "napiu.h" containing the C declarations for NXU routines - I have taken as a basis the F90 implementation as detailed in the NXU* module. The old web pages mention 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.
Cheers,
Freddie
comment:4 Changed 4 years ago by Freddie Akeroyd
- Component set to applications
- Milestone changed from NeXus 4.1 Ready to NeXus 4.2 Ready
comment:5 Changed 4 years ago by Peter Peterson
Caller should allocate the memory for NXUreadhistorgram and similar functions. There will be a parallel function NXUreadhistogrammalloc which allocates memory.
comment:6 Changed 3 years ago by Freddie Akeroyd
- Milestone changed from NeXus 4.2 Ready to NeXus 4.3 Ready
