[fpc-devel] is strnew delphi-compatible?
Michael Van Canneyt
michael at freepascal.org
Thu May 8 10:55:15 CEST 2008
On Thu, 8 May 2008, Klaus Hartnegg wrote:
> TurboPascal and Delphi differ in the way they do strnew.
> Delphi allocates additional two bytes preceding the first
> character to store the length of the string.
> The turbo pascal docs say:
> The allocated space is StrLen(Str) + 1 bytes long.
> The delphi docs say:
> A 16-bit number giving the total amount of memory allocated is stored
> in the two bytes preceding the first character; it is equal to Size+2.
> The file trunk/rtl/inc/strings.pp contains code that looks compatible
> with turbo pascal:
> function strnew(p : pchar) : pchar;
> len : SizeInt;
> if (p=nil) or (p^=#0) then
> if strnew<>nil then
> Is the above source only used in Turbo Compatibility Mode,
> or always? Also in Lazarus?
It should be used in TP mode, it makes no sense to use it in Delphi mode.
Actually, this call is very much deprecated.
More information about the fpc-devel