Quote Originally Posted by Paul McKenzie View Post
However, I don't have the source code to CString at the moment, so I'll ask:

If CString is reference counted, is the reference counting thread-safe? In other words, if that temporary copy used in ProcessContentThreadFunction() is destroyed simultaneously with the destruction of the CString in some_function, is this guaranteed to be OK?
That's a good question. In the implementation of CString on VS2005 and VS2008, I see that the reference count is in-/decremented with interlocked* functions. I think that's enough to make the CoW implementation thread-safe. I.e. if no single CString object is accessed from multiple threads unsynchronized, I don't see how it can fail.