[fpc-pascal] Thread Safety of String

johanns at nacs.net johanns at nacs.net
Wed Jun 4 20:04:49 CEST 2014


On Wed, Jun 04, 2014 at 01:19:33PM -0400, md at rpzdesign.com wrote:
>On 6/4/2014 1:16 PM, Michael Van Canneyt wrote:
>>
>>
>> On Wed, 4 Jun 2014, md at 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?




More information about the fpc-pascal mailing list