This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Re: [open-source] Re: Wish for 2002 ...
- From: Sandy Harris <sandy at storm dot ca>
- To: "Martin v. Loewis" <martin at v dot loewis dot de>
- Cc: aoliva at redhat dot com, netch at iv dot nn dot kiev dot ua, torvalds at transmeta dot com, mouring at etoh dot eviladmin dot org, markus at openbsd dot org, eggert at twinsun dot com, leclerc at austin dot sns dot slb dot com, security-audit at ferret dot lmh dot ox dot ac dot uk, libc-alpha at sources dot redhat dot com, openssh at openbsd dot org
- Date: Sat, 12 Jan 2002 11:44:04 -0500
- Subject: Re: [open-source] Re: Wish for 2002 ...
- References: <Pine.BSO.4.33.0201111306400.4650-100000@etoh.eviladmin.org> <Pine.LNX.4.33.0201111121510.4042-100000@penguin.transmeta.com> <20020112004546.A452@iv.nn.kiev.ua> <orwuyojs44.fsf@free.redhat.lsd.ic.unicamp.br> <200201120113.g0C1Dj001879@mira.informatik.hu-berlin.de>
"Martin v. Loewis" wrote:
> > One approach I like very much is that of stralloc, that I first saw in
> > Amanda code. Concatenating multiple strings into a newly-allocated
> > buffer created with the right size is as simple as stralloc(string1,
> > string2, ..., NULL);
>
> Notice that -liberty offers this as concat(const char* first, ...).
That strikes me as a function worth having, though perhaps not in standard
libraries. It does something standard library functions don't, and it is a
much cleaner interface than you'd get by taking Linus's strdup2() and
adding strdup3(), ...
As for strl*() functions, consider this passage from Henry Spencer's "Ten
Commandments for C Programmers":
http://www.lysator.liu.se/c/ten-commandments.html
" Many customs in this life persist because they ease friction and
" promote productivity as a result of universal agreement, and
" whether they are precisely the optimal choices is much less
" important.
He was talking about brace style, but I think the comment applies here.
strn*() functions may not be precisely optimal, but they should be used
in preference to strl*().
Of course his comments on checking array bounds and on not re-inventing
libray functions also apply.