On Wed, 4 Jun 2014, joha...@nacs.net wrote:

On Wed, Jun 04, 2014 at 01:19:33PM -0400, m...@rpzdesign.com wrote:
On 6/4/2014 1:16 PM, Michael Van Canneyt wrote:


On Wed, 4 Jun 2014, m...@rpzdesign.com wrote:

Hello:

Is a string[30] declaration under Linux thread safe?

No.

Michael.

Just as I suspected.

So every time a new value is assigned to a string[30] variable, memory
is allocated and changed by the compiler, so the internal string pointer
changes as well.

And the only recourse is critical sections for memory access.

Correct?

CHeers,

marco

I still program in Turbo Pascal so I am more of a spectator than a user of Free Pascal. As I understand it the shortstring type is the same as string type in Turbo Pascal. This would make index 0 of variable typed as shortstring[SIZE] an internal length byte and index positions 1 through SIZE the data value of the string. Since, unlike a newer string type, a shortstring is not an object and not a managed string at all, but a simple type like an integer, I would expect shortstring might be thread safe.

Is this the case?

No, exactly the opposite.

Michael.
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to