DragonFly BSD
DragonFly submit List (threaded) for 2006-06
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: Add strndup


From: joerg@xxxxxxxxxxxxxxxxx
Date: Wed, 21 Jun 2006 15:18:40 +0200
Mail-followup-to: submit@crater.dragonflybsd.org

On Wed, Jun 21, 2006 at 01:20:24AM -0700, Matthew Dillon wrote:
>     A memdup that is not string-oriented is a fine idea, but it 
>     would not be something we would add to libc unless there were
>     a pre-existing reasonably standardized function somewhere that
>     did that sort of operation.  It's only a few lines of code but
>     the problem vis-a-vie putting things into libc is standardization.

For memdup there is precedence. The situation is a bit different for
that, since it does fill a hole (copying memory buffer). I don't like
strndup, since the meaning of "copy string up to a fixed length" is
asking for trouble. It doesn't allow to check for truncation without
killing the original intent. Ignoring truncation created enough problems
in the past already, let's not create another API for that.

Joerg



[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]