[Info-vax] C str calls
johnwallace4 at yahoo.co.uk
johnwallace4 at yahoo.co.uk
Mon Aug 24 04:23:31 EDT 2015
On Sunday, 23 August 2015 23:25:42 UTC+1, mcle... at gmail.com wrote:
> On Monday, August 24, 2015 at 4:43:26 AM UTC+10, JF Mezei wrote:
> > C is like a knife.
> >
> > When you don't know about its dangers, you get finger cuts as you handle
> > knife or try to wash it.
> >
> > When you know how to handle the knife, you know how to handle it so that
> > you don't get cut, including how you can slide your fingers on it to
> > wash it and not get cut.
>
> IIRC someone, maybe here, advocated a form of string descriptor for C so that issues of length were easier to deal with - pass the address of the descriptor as an argument rather than the pointer to the string and, separately, the string length.
>
> I'm thinking that the descriptor holding not just maximum length but also current length might be useful, of course with a pointer to the string.
Might have been me. I like descriptors, and the things they enable,
and the things they can (when used properly) prevent. VMS descriptors
already do the things you mention - length of contents (allocated and
maximum), pointer to data.
VMS descriptors also contain other stuff to allow them to be used for
non-string types, e.g. for various kinds of float-to-float conversion
(as per the C example VAXman posted recently).
I also recall that within dwarflib (which some round here will know)
is a neat little library called the extensible string buffer library,
which does most of what you might want from a library for dealing with
extensible strings. I'm surprised I've not seen anything similar
elsewhere. Not sure what the licence is.
More information about the Info-vax
mailing list