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

Re: svn commit: r1618869 - in /subversion/branches/authzperf/subversion: include/svn_string.h libsvn_subr/string.c

From: Ivan Zhakov <ivan_at_visualsvn.com>
Date: Tue, 26 Aug 2014 20:41:06 +0400

On 19 August 2014 18:14, <brane_at_apache.org> wrote:
> Author: brane
> Date: Tue Aug 19 14:14:18 2014
> New Revision: 1618869
>
> URL: http://svn.apache.org/r1618869
> Log:
> On the authzperf branch: Add a stringbuf helper function.
>
[..]

> --- subversion/branches/authzperf/subversion/libsvn_subr/string.c (original)
> +++ subversion/branches/authzperf/subversion/libsvn_subr/string.c Tue Aug 19 14:14:18 2014
> @@ -496,6 +496,21 @@ svn_stringbuf_chop(svn_stringbuf_t *str,
> str->data[str->len] = '\0';
> }
>
> +void
> +svn_stringbuf_leftchop(svn_stringbuf_t *str, apr_size_t nbytes)
> +{
> + if (nbytes > str->len)
> + str->len = 0;
As far I remember we have a API promise that svn_stringbuf_t->data is
always valid nul-terminated string.
While the function seems to be pretty simple, tests will be nice to have IMHO.

> + else
> + {
> + /* Note: This will irretrievably waste nbytes of space in the
> + stringbuf's pool, but unlike the alternative of memmoving the
> + data, it's a constant-time operation. */
> + str->data += nbytes;
> + str->len -= nbytes;
> + str->blocksize -= nbytes;
> + }
> +}
>

-- 
Ivan Zhakov
CTO | VisualSVN | http://www.visualsvn.com
Received on 2014-08-26 18:41:58 CEST

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.