You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@stdcxx.apache.org by Martin Sebor <se...@roguewave.com> on 2008/02/22 20:38:38 UTC

Re: svn commit: r629584 - /stdcxx/trunk/include/string.cc

faridz@apache.org wrote:
> Author: faridz
> Date: Wed Feb 20 11:37:12 2008
> New Revision: 629584
> 
> URL: http://svn.apache.org/viewvc?rev=629584&view=rev
> Log:
> 2008-02-20 Farid Zaripov <fa...@epam.com>
> 
> 	* include/string.cc (__rw_replace): Removed unused variable __delta.
> 	(__rw_replace_aux): Removed unused typedef. Used ::operator new() and
> 	::operator delete() instead of std::allocator::allocate() and
> 	std::allocator::deallocate() respectively (since private base class
> 	std::allocator is not accessible in __rw_replace_aux()).

I don't think we're allowed to bypass the allocator and call new
directly.

Martin

> 
> Modified:
>     stdcxx/trunk/include/string.cc
> 
> Modified: stdcxx/trunk/include/string.cc
> URL: http://svn.apache.org/viewvc/stdcxx/trunk/include/string.cc?rev=629584&r1=629583&r2=629584&view=diff
> ==============================================================================
> --- stdcxx/trunk/include/string.cc (original)
> +++ stdcxx/trunk/include/string.cc Wed Feb 20 11:37:12 2008
> @@ -535,8 +535,6 @@
>              // compute the size of new buffer
>              const size_type __cap = __s3._C_grow (__s3.size (), size_type ());
>  
> -            const size_type __delta = __cap - __s3.size ();
> -
>              // allocate a new buffer
>              _C_string_ref_type *__tmp = __s3._C_get_rep (__cap, __cap);
>  
> @@ -582,9 +580,6 @@
>      typedef _RW::__string_ref<value_type, traits_type, allocator_type>
>      _C_string_ref_type;
>  
> -    typedef _RWSTD_ALLOC_TYPE (allocator_type, value_type)
> -    _C_value_alloc_type;
> -
>  #  else   // if !defined (_RWSTD_NO_STRING_OUTLINED_MEMBER_TEMPLATES)
>  
>  template<class _CharT, class _Traits, class _Allocator>
> @@ -660,8 +655,9 @@
>                      &_RWSTD_REINTERPRET_CAST (const_reference, *__first2);
>  
>                  if (__s.data () <= __ptr && __s.data () + __ssize > __ptr) {
> -                    __tmp = _RWSTD_VALUE_ALLOC (_C_value_alloc_type, __s,
> -                                                allocate (__n2));
> +                    const _RWSTD_SIZE_T __tmp_size = __n2 * sizeof (value_type);
> +                    __tmp = _RWSTD_STATIC_CAST (pointer,
> +                                                ::operator new (__tmp_size));
>                      for (__d = 0; __d < __n2; __d++)
>                          traits_type::assign (*(__tmp + __d), *__first2++);
>                  }
> @@ -674,8 +670,7 @@
>  
>              if (__tmp) {
>                  traits_type::copy (__s._C_data + __pos, __tmp, __n2);
> -                _RWSTD_VALUE_ALLOC (_C_value_alloc_type, __s,
> -                                    deallocate (__tmp, __n2));
> +                ::operator delete (__tmp);
>              }
>              else {
>                  for (__d = 0; __d < __n2; __d++)
> 
> 


Re: svn commit: r629584 - /stdcxx/trunk/include/string.cc

Posted by Martin Sebor <se...@roguewave.com>.
Farid Zaripov wrote:
> From: Martin Sebor [mailto:sebor@roguewave.com]
> To: dev@stdcxx.apache.org
> Subject: Re: svn commit: r629584 - /stdcxx/trunk/include/string.cc
> 
> 
> 
>>> Author: faridz
>>> Date: Wed Feb 20 11:37:12 2008
>>> New Revision: 629584
>>>
>>> URL: http://svn.apache.org/viewvc?rev=629584&view=rev
>>> Log:
>>> 2008-02-20 Farid Zaripov <fa...@epam.com>
>>>
>>>       * include/string.cc (__rw_replace): Removed unused variable __delta.
>>>       (__rw_replace_aux): Removed unused typedef. Used ::operator new() and
>>>       ::operator delete() instead of std::allocator::allocate() and
>>>       std::allocator::deallocate() respectively (since private base class
>>>       std::allocator is not accessible in __rw_replace_aux()).
>> I don't think we're allowed to bypass the allocator and call new
>> directly.
> 
>   Why? Here the operator new() used for allocate the temporary buffer and it's deallocated within this function.

Ah. You're right, that shouldn't matter. Sorry for the noise.

(Although if it's temporary storage, we might want to consider either
allocating it directly on the stack, if the range is reasonably small,
or using the temporary buffer facility, __rw_tmpbuf()).

Martin


Re: svn commit: r629584 - /stdcxx/trunk/include/string.cc

Posted by Farid Zaripov <Fa...@epam.com>.
From: Martin Sebor [mailto:sebor@roguewave.com]
To: dev@stdcxx.apache.org
Subject: Re: svn commit: r629584 - /stdcxx/trunk/include/string.cc



>> Author: faridz
>> Date: Wed Feb 20 11:37:12 2008
>> New Revision: 629584
>>
>> URL: http://svn.apache.org/viewvc?rev=629584&view=rev
>> Log:
>> 2008-02-20 Farid Zaripov <fa...@epam.com>
>>
>>       * include/string.cc (__rw_replace): Removed unused variable __delta.
>>       (__rw_replace_aux): Removed unused typedef. Used ::operator new() and
>>       ::operator delete() instead of std::allocator::allocate() and
>>       std::allocator::deallocate() respectively (since private base class
>>       std::allocator is not accessible in __rw_replace_aux()).
> 
> I don't think we're allowed to bypass the allocator and call new
> directly.

  Why? Here the operator new() used for allocate the temporary buffer and it's deallocated within this function.

Farid.