This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [open-source] Re: Wish for 2002 ...


Hello!

> And if you want concatenate three, four or more strings,
> you will produce another and another variants of strdup${n}()?
> Or simply call asprintf() with loss in efficiency, but quire more
> advantage in human readability?

If you strive for efficiency, you probably shouldn't be using
strcat etc. at all since in almost all real situations you can
know the lengths of the strings at minimum cost and do memcpy()
instead of strcat().

If you want a clean, readable and secure solution, you can for example
create a vararg function like this (I remember seeing something like
that in Apache):

	newstring = pstrcat(str1, str2, ..., strn, NULL)

				Have a nice fortnight
-- 
Martin `MJ' Mares   <mj@ucw.cz>   http://atrey.karlin.mff.cuni.cz/~mj/
Faculty of Math and Physics, Charles University, Prague, Czech Rep., Earth
May the Source be with you...


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]