On Thu, 8 May 2008, Klaus Hartnegg wrote:

> Hi,
> 
> 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;
>       var
>          len : SizeInt;
>       begin
>          strnew:=nil;
>          if (p=nil) or (p^=#0) then
>            exit;
>          len:=strlen(p)+1;
>          getmem(strnew,len);
>          if strnew<>nil then
>            strmove(strnew,p,len);
>       end;
> 
> 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.

Michael.
_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to