* Fixed a bunch or concurreny bugs and memory leaks of the new reference

string stuff.
* It's still not thread-safe for all usage patterns, though, so we might want
  to remove or disable it: if a string is shared between several threads, and
  one of those starts to use a reference, all kinds of problems can happen.
* Some cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24312 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2008-03-08 19:05:09 +00:00
parent 76ec752f89
commit 002b33b720
2 changed files with 113 additions and 112 deletions
+7 -13
View File
@@ -26,7 +26,6 @@ public:
const char* String() const;
int32 Length() const;
int32 CountChars() const;
int32 ReferenceCount() const;
// Assignment
BString& operator=(const BString& string);
@@ -231,7 +230,6 @@ private:
// Data
void _SetLength(int32 length);
void _SetReferenceCount(int32 count);
bool _DoAppend(const char* string, int32 length);
bool _DoPrepend(const char* string, int32 length);
bool _DoInsert(const char* string, int32 offset, int32 length);
@@ -256,7 +254,11 @@ private:
const char* with, int32 withLen);
private:
char* fPrivateData;
inline int32& _ReferenceCount();
bool _IsShareable();
void _FreePrivateData();
char* fPrivateData;
};
@@ -294,13 +296,6 @@ BString::String() const
}
inline int32
BString::ReferenceCount() const
{
return fPrivateData ? (*(((int32 *)fPrivateData) - 2)) : 1;
}
inline BString &
BString::SetTo(const char* string)
{
@@ -441,8 +436,7 @@ operator!=(const char *str, const BString &string)
// #pragma mark - BStringRef
class BStringRef
{
class BStringRef {
public:
BStringRef(BString& string, int32 position);
~BStringRef() {}
@@ -453,7 +447,7 @@ public:
const char* operator&() const;
BStringRef& operator=(char c);
BStringRef &operator=(const BStringRef &rc);
BStringRef& operator=(const BStringRef& rc);
private:
BString& fString;