Re: OpenBSD's strlcpy(3) and strlcat(3)

[ Available lists | Index of freebsd-hackers | Month of Jul 1999 | Week of 15 Jul 1999 | Raw email | View thread | Wrap long lines | Reply | Tag ]
From
Tim Vanderhoek <vanderh@ecf.utoronto.ca>
Date
15 Jul 1999 15:34:08
Subject
Re: OpenBSD's strlcpy(3) and strlcat(3)
Message-ID
19990715183442.A53661@mad


[ Hide this part ]
On Fri, Jul 16, 1999 at 12:15:31AM +0200, Sheldon Hearn wrote:
>
> As I understand it, the goal here is to return to the caller the number
> of bytes copied (however you represent it), so that the caller can
> easily determine whether or not dst is safe for operations demanding a
> null-terminated string.
[...]
> size_t
> fooncat(char *s, const char *append, size_t count)
>
> where the return value is the number of bytes {copied,appended}.

Eeks! This will quickly lead to code like

if (fooncat(string, append, sizeof(string)) != strlen(append))
...

which is rather evil, given that the second strlen(append) would be
completely gratuitous if it weren't for the interface you're
suggesting.


--
This is my .signature which gets appended to the end of my messages.


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message



Elapsed time: 0.158 seconds