stdcxx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject svn commit: r349056 - in /incubator/stdcxx/trunk/include: string string.cc
Date Sat, 26 Nov 2005 01:12:53 GMT
Author: sebor
Date: Fri Nov 25 17:12:48 2005
New Revision: 349056

URL: http://svn.apache.org/viewcvs?rev=349056&view=rev
Log:
2005-11-25  Martin Sebor  <sebor@roguewave.com>

	STDCXX-70
	* string (basic_string): Took into account the fact that the value
	of the reference count when read unguarded may be negative (-1) on
	SPARC V8 when it's being manipulated (incremented or decremented)
	by another thread, and cast it to an unsigned type in expressions
	involving relational operators such as < and <=.
	(begin): Same.
	(append): Same.
	* string.cc (operator=): Same.
	(replace): Same.
	(__replace_aux): Same.

Modified:
    incubator/stdcxx/trunk/include/string
    incubator/stdcxx/trunk/include/string.cc

Modified: incubator/stdcxx/trunk/include/string
URL: http://svn.apache.org/viewcvs/incubator/stdcxx/trunk/include/string?rev=349056&r1=349055&r2=349056&view=diff
==============================================================================
--- incubator/stdcxx/trunk/include/string (original)
+++ incubator/stdcxx/trunk/include/string Fri Nov 25 17:12:48 2005
@@ -937,7 +937,7 @@
 basic_string (const basic_string<_CharT, _Traits, _Allocator> &__s)
     : allocator_type (__s.get_allocator ())
 {
-    if (__s._C_pref ()->_C_get_ref () > 0) {
+    if (size_type (0) < size_type (__s._C_pref ()->_C_get_ref ())) {
         _C_data = __s._C_data;
         _C_pref ()->_C_inc_ref ();
     }
@@ -956,7 +956,7 @@
 basic_string<_CharT, _Traits, _Allocator>::
 begin ()
 {
-    if (_C_pref ()->_C_get_ref () > 1)
+    if (size_type (1) < size_type (_C_pref ()->_C_get_ref ()))
         _C_clone (size ());
 
     // not thread safe: there is exactly one body pointed to by
@@ -1180,7 +1180,8 @@
 {
     const size_type __size = size () + __str.size ();
 
-    if (__size > capacity () || _C_pref ()->_C_get_ref () > 1)
+    if (   capacity () < __size
+        || size_type (1) < size_type (_C_pref ()->_C_get_ref ()))
         return append (__str, size_type (), __str.size ());
 
     traits_type::copy (_C_data + size (), __str.data (), __str.size () + 1);

Modified: incubator/stdcxx/trunk/include/string.cc
URL: http://svn.apache.org/viewcvs/incubator/stdcxx/trunk/include/string.cc?rev=349056&r1=349055&r2=349056&view=diff
==============================================================================
--- incubator/stdcxx/trunk/include/string.cc (original)
+++ incubator/stdcxx/trunk/include/string.cc Fri Nov 25 17:12:48 2005
@@ -2,7 +2,7 @@
  *
  * string.cc - Definitions for the Standard Library string classes
  *
- * $Id: //stdlib/dev/include/string.cc#63 $
+ * $Id$
  *
  ***************************************************************************
  *
@@ -218,7 +218,8 @@
 basic_string<_CharT, _Traits, _Allocator>::
 operator= (const basic_string &__rhs)
 {
-    if (__rhs._C_pref ()->_C_get_ref () > 0) {
+    if (size_type (0) < size_type (__rhs._C_pref ()->_C_get_ref ())) {
+        // `rhs' has reference counting enabled
         __rhs._C_pref ()->_C_inc_ref ();
         _C_unlink (__rhs._C_data);
     }
@@ -356,7 +357,7 @@
 
         // check for shared representation, insufficient capacity,
         // and overlapping regions
-        if (   _C_pref ()->_C_get_ref () > 1
+        if (   size_type (1) < size_type (_C_pref ()->_C_get_ref ())
             || capacity () < __size1
             || __s >= data () && __s < data () + __size0) {
 
@@ -427,7 +428,8 @@
         const size_type __rem = __size0 - __xlen - __pos;
 
         // check for shared representation, insufficient capacity
-        if (_C_pref ()->_C_get_ref () > 1 || capacity () < __size1) {
+        if (   capacity () < __size1
+            || size_type (1) < size_type (_C_pref ()->_C_get_ref ())) {
 
             // need to allocate a new reference
             const size_type __cap = _C_grow (__size0, __size1);
@@ -621,7 +623,8 @@
       size_type __d = 0;
       size_type __rem = __s.size() - __xlen - __pos; // length of bit at the end
       // Check for shared representation, insufficient capacity, 
-      if ( (__s._C_pref()->_C_get_ref () > 1) || (__s.capacity() < __len))
+      if (   __s.capacity() < __len
+          || size_type (1) < size_type (__s._C_pref()->_C_get_ref ()))
       {
         // Need to allocate a new reference.
           const size_type __cap = __s._C_grow (__s.size (), __len);



Mime
View raw message