On Thu, 22 Dec 2005, Mark Taylor wrote:
> I retain a philosophical uneasiness on the grounds that I don't think
> calls to a low-level library like HDS should return the same
> information in more than one form. Perhaps though I shouldn't be
What do you mean? I'm happy to hear your opinion on the API given that it
must be C like but also given that most people want to be responsible for
allocating their own buffer. The reason there is a character buffer and an
array of pointers is because that was deemed to be the easiest way to get
the char** array without relying on the library doing lots of mallocing
that could easily lead to memory leaks (at least without providing a
helper function for freeing all the memory in the strings).
Note that in datGetC the caller provides the space for the string buffer
to be stored so that datGet1C is the same except that you also get
pointers to the start of each string and the strings are nul-terminated.
In all the C code I've seen that is trying to use _CHAR*N arrays from HDS,
they all try to convert them to C strings immediately afterwords. The idea
is to make it easy for the C programmer to get and store 1-D string
arrays.
I'm proposing that for the C interface datGetNC simply returns the buffer
without any termination and datPutNC takes the buffer.
> surprised that Tim favours a more TMTOWTDI approach. This is
> probably just me being anal anyway - I'm certainly not going to
> lodge any protest against this solution.
>
Are you against the API as a whole or just the extra NULL in the pointer
array?
>> 1. Everyone reads the documentation (which surprises me since SUN92 is
>> not up to date) and no core dumps ensue
>
> I would have if I'd known it was there.
I wasn't picking on you since there is no documentation at all. Hardly any
of the new C implementations have documentation and SUN92 is now the only
place where the fortran interface is documented. HDS is in extremely bad
shape now from a documentation standpoint.
>
> A merry christmas to all our readers - and like Peter says, Tim you
> really should take a few hours off coding for a turkey sandwich or
> something.
>
We don't get Boxing Day in the US so I've only got one day off work next
week...
--
Tim Jenness
JAC software
http://www.jach.hawaii.edu/~timj
|