[Scummvm-cvs-logs] SF.net SVN: scummvm:[49323] scummvm/trunk/common/str.h

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Sun May 30 15:10:44 CEST 2010


Revision: 49323
          http://scummvm.svn.sourceforge.net/scummvm/?rev=49323&view=rev
Author:   lordhoto
Date:     2010-05-30 13:10:44 +0000 (Sun, 30 May 2010)

Log Message:
-----------
Fix non-const version of Common::String::begin.

Common::String::begin now assures the storage is a unique one, i.e. there are
no other Common::String objects pointing at it. This allows for safe use of
the writable iterators (and thus fixes the test case added with my last commit)

Modified Paths:
--------------
    scummvm/trunk/common/str.h

Modified: scummvm/trunk/common/str.h
===================================================================
--- scummvm/trunk/common/str.h	2010-05-30 13:10:23 UTC (rev 49322)
+++ scummvm/trunk/common/str.h	2010-05-30 13:10:44 UTC (rev 49323)
@@ -222,6 +222,12 @@
 	typedef const char *  const_iterator;
 
 	iterator begin() {
+		// Since the user could potentionally
+		// change the string via the returned
+		// iterator we have to assure we are
+		// pointing to an unique storage.
+		makeUnique();
+
 		return _str;
 	}
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list