[fpc-devel]StrPas error (was fpc v1.1 cpupara memleak)

Sergey Korshunoff seyko at comail.ru
Sun Jul 14 16:24:06 CEST 2002

> It's simpler/safer to just put the free in a finalization section of
> paramgr. It's fixed now.
> Jonas

There is another small problem: StrPas realization.

  We have problems with
  because StrPas do not check its parm for a NIL equivalence.
  And StrLen() can not be used to calculate a length of NIL
  (as I understand from a Kylix souirces).

  A suggested  StrPas realization is like StrPas realization in Kylix: it     
 uses a compiler function to convert PChar to string.

diff -urN FPC-MY-0-1.old/fpc/rtl/objpas/syspch.inc 
--- FPC-MY-0-1.old/fpc/rtl/objpas/syspch.inc	Tue Jun 11 06:50:40 2002
+++ FPC-MY-0-1/fpc/rtl/objpas/syspch.inc	Tue Jun 11 06:52:28 2002
@@ -36,13 +36,8 @@
 {  StrPas converts a PChar to a pascal string  }
 function StrPas(Str: PChar): string;
-  l: Integer;
-  l := StrLen(Str);
-  SetLength(result, l);
-  if l > 0 then
-    Move(Str^, result[1], l);
+  Result:=Str;
 end ;
 {  StrAlloc allocates a buffer of Size + 4

More information about the fpc-devel mailing list