Slowly ploughing through HDS removing Fortran code....
Over the weekend I got datPut1C working with nul-terminated char *[]
arrays. My policy is:
datPutC - Takes Fortran-style char * buffer containing spaces
datPutNC - Takes same as datPutC
datPut1C - Takes nul terminated char **
datPutVC - Same as datPut1C
on the basis that you then get a choice over using a char buffer or a C
style array of pointers. (Note that fortran view of datPutVC and datPut1C
do not change of course)
For the datGet routines you pass in a pointer to pre-allocated memory that
should receive the data. This works fine for numeric types and the Fortran
char* buffers so datGetC and datGetNC work fine. My issue is with the
memory management associated with the to-be-written datGet1C and datGetVC.
Who should create the array of pointers to pre-allocated strings? Should
the caller to datGet1C pass in a char *** and allow datGet1C to allocate
all the strings and pointer arrays? Should the caller pass in the char**
and the space they have allocated to each element in the char**? ie they
pass in the minimum longest length of each of the strings and the number
of elements in the pointer array. If the former, should HDS provide a helper
function to free the char**? Or should that be up to the to programmer?
Votes appreciated.
--
Tim Jenness
JAC software
http://www.jach.hawaii.edu/~timj
|