[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

apr_pstrndup not the best name?

From: Jim Blandy <jimb_at_savonarola.red-bean.com>
Date: 2000-10-24 22:55:45 CEST

There may be a larger pattern here I'm missing, but the name
`apr_pstrndup' makes me think of the ANSI `strn' functions ---
strncat, strncmp, and strncpy. However, its behavior doesn't match.

Each ANSI `strn' function is like the corresponding `str' function,
except that it takes an additional argument N which establishes the
*maximum* number of characters to process --- if we find a '\0' in the
string before the N'th, we'll stop there. So the effective length is
the shorter of N and strlen (the string).

The `apr_pstrndup' function, however, uses the length as the number of
bytes to copy, and ignores any '\0' characters it finds. This is like
the ANSI `mem' functions. So if the implementation of apr_pstrndup is
correct (it's certainly the behavior I want), perhaps it should be
named apr_pmemdup. But in any case, `strn' seems like the wrong
namespace.
Received on Sat Oct 21 14:36:12 2006

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.