Trying to use compress / uncompress; the versions with two pointers.

When I do compress --> uncompress the uncompressed buffer contains

the correct data but the uncompress function returns 0. How do I get

the uncompressed length? I expected uncompress to return that value.

See code below what I try to do:

--Paul

- Code: Select all
`program Project1;`

{$APPTYPE CONSOLE}

uses

sysutils,

madzip;

const

bufsrc = 100;

bufdest = 120;

var

psrc, pdest: pbytearray;

n, nl: integer;

begin

GetMem(psrc, bufsrc);

for n := 0 to bufsrc - 1

do psrc^[n] := n mod 4;

GetMem(pdest, bufdest);

nl := madzip.Compress(psrc, pdest, bufsrc, bufdest);

WriteLn('nl = ', nl);

for n := 0 to bufsrc - 1

do psrc^[n] := 0;

n := madZip.Uncompress(pdest, psrc, bufsrc, bufdest);

WriteLn('n = ', n);

for n := 0 to bufsrc - 1

do if psrc[n] <> n mod 4

then

WriteLn('Error, n = ', n, ' value = ', psrc[n], ' expected ', n mod 4);

end.