Date: Sat, 12 May 2001 12:07:56 -0700 From: Bakul Shah <bakul@bitblocks.com> To: dan@BSDpro.com Cc: freebsd-hackers@freebsd.org Subject: Re: adding a new function to libc Message-ID: <200105121907.PAA13219@tonnant.cnchost.com> In-Reply-To: Your message of "Sat, 12 May 2001 02:10:45 EDT." <01051202104500.95296@blackhole.BSDpro.com>
next in thread | previous in thread | raw e-mail | index | archive | help
> Any comments, suggestions, swears concerning adding a new function, > strndup(), to libc? Many very good programmers I know carry around a library of useful functions (and usually don't bother about inclusion in libc). So I would suggest first you should keep this function in your own library for a few years and *only* then, and only if from experience you truly think it to be generally useful should you propose it for inclusion in a standard library. And *when* you do that you should a) present a correct version of the function (not a buggy one as you did here) and, more importantly b) a clear explanation of its function including how boundary conditions are handled. For your own library you don't have to jump through these hoops; this is necessary only when you want to let loose one of your favorite functions on unsuspecting libc users! Then the function behavior must be fully and carefully specified. Even for your own use, as was suggested by Valentin Nechayev, the strangely named function "strnlen(str, max)" is a better lower level function since it guarantees "str" won't be traversed beyond "max" chars and it is likely to be useful in more situations. As suggested by Terry Lambert, `asnprintf' would be another alternative. <meta-comment> Though IMHO these string functions have sprouted like weeds, for very little added functionality. The fact str[a-z]* is reserved namespace should tell you how bad the situation is. What is needed is a decent unicode string library, derived from the collective experience with perl scripts. Unicode strings should be counted instead of null terminated so we are talking about a brand new set of functions. May be such a library can be standardized in a future standards effort after some experience with it. </meta comment> To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200105121907.PAA13219>