MT string, second try

Benjamin Kosnik bkoz@cygnus.com
Sat Apr 1 00:00:00 GMT 2000


some typos:

>  	_M_grab(const _Alloc& __alloc1, const _Alloc& __alloc2)
> -	{ return (_M_state >= 0 && __alloc1 == __alloc2) ?
> +	{ return (!_M_leaked() && __alloc1 == __alloc2) ?
>  	    _M_refcopy() : _M_clone(__alloc1);  }

no _M_leaked() MF.

Assuming you mean

_M_is_leaked()

>        void 
>        _M_leak()    // for use in begin() & non-const op[]
>        { 
> -	if (_M_rep()->_M_state >= 0) 
> +	if (!_M_rep()->_M_leaked()) 
>  	  _M_leak_hard(); 
>        }

same here



and then here...

  template<typename _CharT, typename _Traits, typename _Alloc>
    void
    basic_string<_CharT, _Traits, _Alloc>::_M_leak_hard()
    {
      if (_M_rep()->_M_is_shared()) 
	_M_mutate(0, 0, 0);
+      _M_rep()->_M_set_leaked();
-      _M_rep()->set_leaked();
    }



Also, there are bunches of places in the string code where I see stuff like

// XXX MT

if this code is not MT-safe, can that stuf be cleaned up please? Or 
explained...

with these changes, it compiles on x86/linux. If they are correct, let me 
know and I'll check in. Perhaps then it can be tested? Does anybody have 
tests....

-benjamin


More information about the Libstdc++ mailing list