You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Ivan Zhakov <iv...@visualsvn.com> on 2014/08/26 18:41:06 UTC

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

On 19 August 2014 18:14,  <br...@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

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

Posted by Branko Čibej <br...@wandisco.com>.
On 26.08.2014 19:15, Branko Čibej wrote:
> On 26.08.2014 18:41, Ivan Zhakov wrote:
>> On 19 August 2014 18:14,  <br...@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.
> You are correct, this is an omission; thanks for pointing it out. Will fix.

Fixed in r1621178.

-- Brane


-- 
Branko Čibej | Director of Subversion
WANdisco | Realising the impossibilities of Big Data
e. brane@wandisco.com

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

Posted by Branko Čibej <br...@wandisco.com>.
On 26.08.2014 18:41, Ivan Zhakov wrote:
> On 19 August 2014 18:14,  <br...@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.

You are correct, this is an omission; thanks for pointing it out. Will fix.

-- Brane

-- 
Branko Čibej | Director of Subversion
WANdisco | Realising the impossibilities of Big Data
e. brane@wandisco.com