Board index » delphi » Memory Usage Differences (Delphi I vs BP OWL)

Memory Usage Differences (Delphi I vs BP OWL)

The following code works great in BP OWL but fails under
Delphi V1:

 VAR _DCL : PDCL;
     Fils : PACHAR; {array[0..xx] of pchar}
     Fil  : ARRAY[0..12] OF CHAR;
     ZipF : ARRAY[0..144] OF CHAR;
  ...
 StrCopy(Fil,'*.doc'); StrCopy(ZipF,'c:\windows\temp\test.zip');
 GetMem(Fils,SizeOf(PCHAR)); Fils^[0] := @Fil;
 WZInitADCL(_DCL,HInstance,HWindow {Handle},0);
 WITH _DCL^ DO
  BEGIN
   WITH lpUMB^ DO
    StrCopy(szUnzipToDirName,'c:\windows\temp');
   OverWrite := TRUE;
   ArgC := 1;
   lpszZipFN := @ZipF;
   FNV := Fils;
  END;  
 Ret := WZ_UnZip(_DCL); {wrapper call around dll call}
 WZDestroyDCL(_DCL);
 FreeMem(Fils,SizeOf(PCHAR));
 IF Ret <> wze_OK THEN ...;

This code sets up and calls the info-zip group's win16 unzip
DLL (released recently with unzip version 5.2).
Under BP, no problems.  Under Delphi, the only way to make it
work is to change the getmem/freemem calls to use
SizeOf(PCHAR)*2.  This works for one or two passes through
the code. The second/third pass causes a GPF within the DLL.
If the file name vector is removed (FNV and ArgC set to 0),
Delphi does not fail.  What are the addressing differences
between BP/OWL and delphi that would make this fail?  Or is
there something different in way BP and Delphi handle memory
and memory accesses?  We've been beating our heads for a few
days now.

                         Mike

 

Re:Memory Usage Differences (Delphi I vs BP OWL)


mg>The following code works great in BP OWL but fails under
mg>Delphi V1:
mg> GetMem(Fils,SizeOf(PCHAR)); Fils^[0] := @Fil;

A PCHAR is 4 bytes (it's just a pointer). You should allocate enough bytes to
contain an entire path (for win95 compatibility, use 260).

--
Mr. HillBilly (hillbi...@programmers.bbs.no)
Programmers BBS er oppe igjen, n? p? tlf. 22217666/22217669!
 tHyperSoft HyperReader 1.0t

Re:Memory Usage Differences (Delphi I vs BP OWL)


In article 5...@cisu2.jsc.nasa.gov, Michael Slack <mgsl...@rsoc.rockwell.com> () writes:

Quote
>The following code works great in BP OWL but fails under
>Delphi V1:

> VAR _DCL : PDCL;
>     Fils : PACHAR; {array[0..xx] of pchar}

_____________^^^^^^

Could this be your problem?  What is a PACHAR?

Best regards,
Michael Vincze
vin...@ti.com

Quote
>     Fil  : ARRAY[0..12] OF CHAR;
>     ZipF : ARRAY[0..144] OF CHAR;
>  ...
> StrCopy(Fil,'*.doc'); StrCopy(ZipF,'c:\windows\temp\test.zip');
> GetMem(Fils,SizeOf(PCHAR)); Fils^[0] := @Fil;
> WZInitADCL(_DCL,HInstance,HWindow {Handle},0);
> WITH _DCL^ DO
>  BEGIN
>   WITH lpUMB^ DO
>    StrCopy(szUnzipToDirName,'c:\windows\temp');
>   OverWrite := TRUE;
>   ArgC := 1;
>   lpszZipFN := @ZipF;
>   FNV := Fils;
>  END;  
> Ret := WZ_UnZip(_DCL); {wrapper call around dll call}
> WZDestroyDCL(_DCL);
> FreeMem(Fils,SizeOf(PCHAR));
> IF Ret <> wze_OK THEN ...;

>This code sets up and calls the info-zip group's win16 unzip
>DLL (released recently with unzip version 5.2).
>Under BP, no problems.  Under Delphi, the only way to make it
>work is to change the getmem/freemem calls to use
>SizeOf(PCHAR)*2.  This works for one or two passes through
>the code. The second/third pass causes a GPF within the DLL.
>If the file name vector is removed (FNV and ArgC set to 0),
>Delphi does not fail.  What are the addressing differences
>between BP/OWL and delphi that would make this fail?  Or is
>there something different in way BP and Delphi handle memory
>and memory accesses?  We've been beating our heads for a few
>days now.

>                         Mike

Re:Memory Usage Differences (Delphi I vs BP OWL)


Quote
vin...@ti.com (Michael Vincze) wrote:

> In article 5...@cisu2.jsc.nasa.gov, Michael Slack <mgsl...@rsoc.rockwell.com> () writes:
> >The following code works great in BP OWL but fails under
> >Delphi V1:

> > VAR _DCL : PDCL;
> >     Fils : PACHAR; {array[0..xx] of pchar}

> _____________^^^^^^

> Could this be your problem?  What is a PACHAR?

Sorry about being brief on self defined types.  PACHAR
is defined as:

 TYPE PACHAR : ^TACHAR;
      TACHAR : ARRAY[0..8187] OF PCHAR;

This was to match up to the C definition of: char **FNV
(needed a pointer to an array of pointers).

                          Mike

Other Threads