apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Trawick <traw...@attglobal.net>
Subject Re: apr_strcat optimization(s)
Date Tue, 19 Jun 2001 18:08:26 GMT
Doug MacEachern <dougm@covalent.net> writes:

> > 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';

cp doesn't point to the end of the string to be built yet.  If you had

  *(cp + len) = '\0';

then I'd believe you.

-- 
Jeff Trawick | trawick@attglobal.net | PGP public key at web site:
       http://www.geocities.com/SiliconValley/Park/9289/
             Born in Roswell... married an alien...


Mime
View raw message