This is the mail archive of the libc-alpha@sourceware.org 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: [PATCH v3] Implement strlcpy [BZ #178]


On 10/29/2015 02:50 PM, Paul Eggert wrote:
We can pair this with similar phrasing under strlcpy -- something like the following perhaps (this wording assumes strlcpy is changed to use memmove):"Often @code{strlcpy} is not what you want, because it does not null-terminate the destination if the destination's size is zero,it can leave junk data behind in the destination, it can do useless work when the source is long and the destination short, and it may truncate the destination. Although one alternative is @code{strncpy}, it is usually better to use dynamic memory allocation and functions such as @code{strdup} or @code{asprintf} to construct strings."

One more thing: we should add "it requires the source to be null-terminated even when it is longer than the destination".


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