[fpc-devel] CmdLine

Daniël Mantione daniel.mantione at freepascal.org
Wed Oct 18 22:14:41 CEST 2006



Op Wed, 18 Oct 2006, schreef Michael Van Canneyt:

> 
> 
> On Wed, 18 Oct 2006, Peter Vreman wrote:
> 
> > >> Does the CmdLine variable in the System unit exist for Delphi/TP/...
> > >> compatibility ?
> > >
> > > Delphi compatibility.
> > >
> > > By the way, I have a patch ready which turns it into a property, which
> > > prevents some code being pulled in Hello World kind of apps.
> > 
> > That is the best solution. It will then also be readonly.
> 
> Do you get rid of the duplicate argc/argv and cmdline, then ?

No. Because cmdline is a Pchar which points to the heap, it cannot be 
calculated on the fly; that would be a memory leak. Instead it is 
calculated on the first use. This means however that it still needs to be 
deallocated just like before.

Daniël

> Code like
> 
> {$if defined(MSWINDOWS) or defined(OS2)}
>   { finally release the heap if possible, especially
>     important for DLLs }
>   for i:=0 to argc do
>     sysfreemem(argv[i]);
>   sysfreemem(argv);
> {$endif}
> {$if defined(LINUX) or defined(BSD)}
>   sysfreemem(cmdline);
> {$endif}
> 
> seems rather strange to me...
> 
> Michael.
> _______________________________________________
> fpc-devel maillist  -  fpc-devel at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-devel
> 


More information about the fpc-devel mailing list