[prev in list] [next in list] [prev in thread] [next in thread] 

List:       secprog
Subject:    Re: Are bad developer libraries the problem with M$ software?
From:       Luciano Miguel Ferreira Rocha <strange () nsk ! no-ip ! org>
Date:       2002-11-26 15:03:24
[Download RAW message or body]

On Mon, Nov 25, 2002 at 08:59:02PM -0800, The Amazing Dragon wrote:
> If you know the total
> length and the number of free characters you already know where the end
> of the existing string (dst+total-free, or dst+used) at which point why
> not use strncpy() which doesn't have the overhead of using a strlen()
> equivilant internally?

In that case, sure, no need to strncpy (in fact, in my usage I often use
memcpy, not even strncpy).

But I found your words a little confusing:
> > > Also given the total space it is very easy for
> > > strncat() to internally compute the free space
> > > (when searching for the end of the string, simply decrement
> > > the space counter)
^^^ searching for the end of the string is what strlen does, that's why my
confusion.
> > > this also has
> > > better performance since you don't need to use strlen() first

Regards,
Luciano Rocha

-- 
Consciousness: that annoying time between naps.
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic