Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2002-07

fpc v1.1 cpupara memleak

4 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Sergey Korshunoff

Hi!

diff -urN FPC-MY-1.old/fpc/compiler/i386/cpupara.pas FPC-MY-1/fpc/compiler/i386/cpupara.pas
--- FPC-MY-1.old/fpc/compiler/i386/cpupara.pas Fri Jul 12 11:16:39 2002 +++ FPC-MY-1/fpc/compiler/i386/cpupara.pas Fri Jul 12 11:17:43 2002 @@ -61,8 +61,10 @@

       end;

-begin
+initialization

    paramanager:=ti386paramanager.create;

+finalization
+ paramanager.free;
end.
{
$Log: cpupara.pas,v $
diff -urN FPC-MY-1.old/fpc/compiler/powerpc/cpupara.pas FPC-MY-1/fpc/compiler/powerpc/cpupara.pas
--- FPC-MY-1.old/fpc/compiler/powerpc/cpupara.pas Fri Jul 12 11:16:40 2002 +++ FPC-MY-1/fpc/compiler/powerpc/cpupara.pas Fri Jul 12 11:18:28 2002 @@ -134,8 +134,10 @@

          getfuncretloc.register:=R_3;
       end;

-begin
+initialization

    paramanager:=tppcparamanager.create;

+finalization
+ paramanager.free;
end.
{
$Log: cpupara.pas,v $

Reply by email

Jonas Maebe
to Sergey Korshunoff
Sergey Korshunoff wrote 6 lines
-begin +initialization paramanager:=ti386paramanager.create; +finalization + paramanager.free; end.

[snip]

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

Jonas

Reply by email

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

Nice!
There is another small problem: StrPas realization.

  We have problems with
    GetEnvironmentVariable('NON_EXISTING_ONE');
  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/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;
-var
-  l: Integer;
 begin
-  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

Reply by email

Jonas Maebe
to Sergey Korshunoff
Sergey Korshunoff wrote 6 lines
> It's simpler/safer to just put the free in a finalization section of > paramgr. It's fixed now. Nice! There is another small problem: StrPas realization. uses a compiler function to convert PChar to string.

[snip]

Thanks, it's fixed.

Jonas

Reply by email