[Verse-dev] R5: Introducing v_strlcpy()

Emil Brink emil at obsession.se
Mon Feb 21 10:33:34 CET 2005


Hi.

Just wanted to note that I've added a new source module to the upcoming
R5 release of the Verse core.

Called v_util.[ch], it currently defines just this single function:

extern char * v_strlcpy(char *dst, const char *src, size_t size);

This is a simple string-copying function, that copies at most <size>
bytes from <src> to <dst>. It will always 0-terminate the destination
string. It currently returns the destination buffer <dst>; I'm not
sure what the most useful return value actually is. OpenBSD which I
was very inspired of (thanks to Camilla) returns the length of the
non-copied part of the source, which I guess is useful but takes
longer to compute. Also the Verse codebase doesn't really deal with
dynamic string buffers that could need resizing in such cases, so
I opted out.

I also opted out of naming it "v_u_strlcpy()" since doing so seemed
a bit excessive.

Anyway, it's now open season on any code that copies string data and
does so without using strlcpy(). I've done a few cases already, but
I'm sure there are plenty more.

Regards,

/Emil


More information about the Verse-dev mailing list