Commit Graph

15 Commits

Author SHA1 Message Date
Axel Dörfler 4b83262008 * _Realloc() did not initialize the reference count either.
* _Alloc() can now preserve the original reference count, only _Clone()
  still initializes it to 1. As Karsten pointed out, this is necessary to
  preserve the "shareable" status of the private data.
* I hope that's finally it. What happened to our testing suite, anyway? :-)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24355 a95241bf-73f2-0310-859d-f6bbb57e9c96
2008-03-10 22:56:27 +00:00
Axel Dörfler bf4ddb61e1 * As found by Karsten, the reference count was not initialized in
_ReplaceAtPositions(), and _DoCharacterEscape() (we don't need to preserve
  it, though, as it must be 1).
* Factored out an _Alloc() method which is now always called when the private
  data is allocated. It also takes care of correct initialization (and thus
  fixes the above problem).
* This fix finally allows turning on reference counting again, thanks Karsten!
* Minor cleanup, renamed "oldAdr"/"newAdr" to "oldString", resp. "newString".


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24348 a95241bf-73f2-0310-859d-f6bbb57e9c96
2008-03-10 19:14:05 +00:00
Axel Dörfler 688c14266c * After my last change, _IsShareable() was called on the wrong string in the
copy constructors, effectively turning of references completely.
* Since that caused troubles (NetPositive now crashes when started), I
  temporarily disabled references by letting _IsShareable() always return
  false until the issue is resolved.
* _FreePrivateData() now sets the fPrivateData member to NULL, and is also
  safe to be called when fPrivateData is NULL.
* Removed my comment about the threading problem in _Detach() and _DetachWith()
  as that just couldn't happen.
* _Clone() must not use memcpy() as the string pointed to by "data" might not
  be as long as "length".
* LockBuffer() now marks a string as unshareable.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24345 a95241bf-73f2-0310-859d-f6bbb57e9c96
2008-03-10 14:14:44 +00:00
Axel Dörfler 002b33b720 * 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
2008-03-08 19:05:09 +00:00
Karsten Heimrich 93608e10d1 * fixed coding style...
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24103 a95241bf-73f2-0310-859d-f6bbb57e9c96
2008-02-24 22:22:43 +00:00
Stefano Ceccherini 576e2bf833 Patch by Julun: implements a refcounted BString. Thank You!
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24102 a95241bf-73f2-0310-859d-f6bbb57e9c96
2008-02-24 21:16:58 +00:00
Axel Dörfler 43cca04a9a Cleanup.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19731 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-01-06 18:06:38 +00:00
Stefano Ceccherini 5480b4590e Another patch from Oliver Tappe: BString behaves better when the user supplies out-of bounds values in Insert(), Remove(), etc.
Code is refactored, and it fully complies with our guidelines.
Tests have been updated too (hint: try the replace tests with R5 and our implementation...)


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5348 a95241bf-73f2-0310-859d-f6bbb57e9c96
2003-11-13 07:35:16 +00:00
Ingo Weinhold 67330a1267 Added missing _DoReplace().
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2718 a95241bf-73f2-0310-859d-f6bbb57e9c96
2003-02-15 20:08:36 +00:00
Stefano Ceccherini 769a895450 Corrected some inaccuracies imported from the BeOS headers:
CapitalizeEachWord() DOESN'T capitalize words separated by spaces, it
capitalizes words separated by non alphabethical  characters.
FindLast(char, int32) prototype was misleading.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2008 a95241bf-73f2-0310-859d-f6bbb57e9c96
2002-11-18 13:45:27 +00:00
shatty 1c5c50fc82 fixed newline at end of file.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1215 a95241bf-73f2-0310-859d-f6bbb57e9c96
2002-09-27 23:44:26 +00:00
Stefano Ceccherini a15ed5a14a fixed a typo
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1193 a95241bf-73f2-0310-859d-f6bbb57e9c96
2002-09-26 14:22:16 +00:00
Stefano Ceccherini 6ad2c5a19c Added a first BString header
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@987 a95241bf-73f2-0310-859d-f6bbb57e9c96
2002-09-06 07:12:06 +00:00
Ingo Weinhold 9377918226 This file shadows Be's header. So if it doesn't contain anything, iclude at least the original header.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@17 a95241bf-73f2-0310-859d-f6bbb57e9c96
2002-07-09 21:39:34 +00:00
ejakowatz 52a3801208 It is accomplished ...
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10 a95241bf-73f2-0310-859d-f6bbb57e9c96
2002-07-09 12:24:59 +00:00