[fpc-pascal] Unicodestrings and Assign(File)

Marco van de Voort marcov at stack.nl
Sat May 19 18:59:54 CEST 2012

In our previous episode, Sven Barth said:
> > Think what happens if those are simply "cloned".
> >
> Why shouldn't reference types work in threadvard records? As long as the 
> reference count mechanism does it's work correctly it should work.

Afaik because the ref count mechanism doesn't. The cloning process might be
done by the OS.

So you have a record with that points to an ansistring with ref count 1, and
then you create twenty threads, and you have 20 records that point to an
ansistring with refcount 1.

For the same reason, the content of the buffer is duplicated.

If e.g. you have 'blabla' in a threadvar filerec buffer, create a few
threads and flush them, you will have several times 'blabla'  written

But Pierre and Sergei have done so much on TLS, that I don't know the
current situation.

> >> I hope other core developers comment on this as well, as I'm not so firm
> >> regarding the consequences of such changes...
> >
> > There are some interesting discussions on various lists you might want to
> > read.... :-)
> I know these discussions, but somehow the results/decisions (if there 
> were any) got lost in the noise...

This is the part where there is still consensus. It gets harder when you get
to classes, or global variables or functions that write/return strings.

More information about the fpc-pascal mailing list