This is the mail archive of the
libstdc++@sourceware.cygnus.com
mailing list for the libstdc++ project.
std::basic_string<> and threads - patch
- To: libstdc++ at sourceware dot cygnus dot com
- Subject: std::basic_string<> and threads - patch
- From: Ryszard Kabatek <rumcajs at gmx dot net>
- Date: Sat, 19 Feb 2000 09:17:53 +0100 (MET)
2000-02-19 Ryszard Kabatek <rumcajs@gmx.net>
* bits/basic_string.h: Add _S_initial_state in _Rep
* bist/string.tcc: use this value for the initialization of
_M_state
I used a simple preprocessor guard:
#if 1
// enable reference counting
enum _State {_S_initialstate = 0};
#else
// disable reference counting
enum _State {_S_initialstate = -1};
#endif
Perhaps we should define a macro for this case.
--
Ryszard Kabatek
Sent through Global Message Exchange - http://www.gmx.net
diff -c2p bits/basic_string.h ./basic_string.h
*** bits/basic_string.h Fri Feb 18 08:20:08 2000
--- ./basic_string.h Fri Feb 18 20:31:50 2000
*************** namespace std {
*** 150,153 ****
--- 150,160 ----
// m = ((npos - sizeof(_Rep))/sizeof(CharT)) - 1
// In addition, this implementation quarters this ammount.
+ #if 1
+ // enable reference counting
+ enum _State {_S_initial_state = 0};
+ #else
+ // disable reference counting
+ enum _State {_S_initial_state = -1};
+ #endif
static size_type _S_max_size;
static _CharT _S_terminal;
Only in .: bits
Only in .: string.diff
diff -c2p bits/string.tcc ./string.tcc
*** bits/string.tcc Fri Feb 18 08:21:50 2000
--- ./string.tcc Fri Feb 18 20:17:13 2000
*************** namespace std
*** 286,290 ****
traits_type::move(_M_data() + __pos + __len2, __src, __how_much);
}
! _M_rep()->_M_state = 0;
_M_rep()->_M_length = __new_size;
_M_data()[__new_size] = _Rep::_S_terminal; // grrr. (per 21.3.4)
--- 286,290 ----
traits_type::move(_M_data() + __pos + __len2, __src, __how_much);
}
! _M_rep()->_M_state = static_cast<int>(_Rep::_S_initial_state);
_M_rep()->_M_length = __new_size;
_M_data()[__new_size] = _Rep::_S_terminal; // grrr. (per 21.3.4)
*************** namespace std
*** 310,316 ****
{
if (_M_rep()->_M_state < 0)
! _M_rep()->_M_state = 0;
if (__s._M_rep()->_M_state < 0)
! __s._M_rep()->_M_state = 0;
if (this->get_allocator() == __s.get_allocator())
{
--- 310,316 ----
{
if (_M_rep()->_M_state < 0)
! _M_rep()->_M_state = static_cast<int>(_Rep::_S_initial_state);
if (__s._M_rep()->_M_state < 0)
! __s._M_rep()->_M_state = static_cast<int>(_Rep::_S_initial_state);
if (this->get_allocator() == __s.get_allocator())
{
*************** namespace std
*** 359,363 ****
_Rep *__p = new (__place) _Rep;
__p->_M_capacity = __capacity;
! __p->_M_state = 0; // one reference
__p->_M_length = 0;
return __p;
--- 359,363 ----
_Rep *__p = new (__place) _Rep;
__p->_M_capacity = __capacity;
! __p->_M_state = static_cast<int>(_Rep::_S_initial_state);
__p->_M_length = 0;
return __p;