[fpc-pascal]Strange Segfault...

Michael Van Canneyt michael.vancanneyt at wisa.be
Fri Jul 11 13:33:31 CEST 2003


On Fri, 11 Jul 2003, Matt Emson wrote:

>
> BTW, if you are using longstrings, you shouldn't be passing by reference, as
> the longstring (AnsiString) is already a pointer. If FPC handles memory in a
> similar way to Delphi with respects to longstrings, it may cause a
> performance hit if the string is fairly long (say 1024+ chars).

Normally the performance hit is nearly zero.
No copying is done, only a reference count is increased. As it is a
const, it cannot be assigned to anyway, so there will be no copy-on-
write operation.

It is always a good idea to use 'Const' parameters as it will stop you from
assigning values to the parameter in your procedure. Just proper coding.

Michael.





More information about the fpc-pascal mailing list