On Tue, Dec 1, 2009 at 2:28 PM, Jonas Maebe <jonas.ma...@elis.ugent.be> wrote: > > On 01 Dec 2009, at 18:03, Luca Olivetti wrote: > >> I always protect multithreaded sting access with a critical section. >> Do you mean it is not needed? > > The reference counting of ansistrings/... is thread safe. Accessing the > characters etc > still requires explicit synchronization if at least one writer is involved. >
(I guess Jonas intended to avoid a complicate answer, but let me complicate it for you ;-) ... and the AnsiString has refcount = 1. If you access the string through a by-value parameter or assign it to a temporary variable, you're safe too. (unless, of course, some screwed code change the contents of the string in-place - e.g. with a typecast to pchar or some other pointer) -Flávio _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal