On 19 Jun 2001, Jeff Trawick wrote:
> better to memcpy() and then set *cp to '\0' when done... strncpy() is
> more expensive because
agreed.
> More importantly, I think your patch is broken. Likely I'm confused,
> but I don't see how the terminating '\0' gets added in your patch.
> strncpy() will bail out before adding '\0' since it has exhausted the
> len bytes it thinks are available in the buffer pointed to by cp.
no, the result string is terminated before going into the loop:
/* Allocate the required string */
res = (char *) apr_palloc(a, len + 1);
cp = res;
*cp = '\0';