701b5a29032e3615a9152440d143e09ece209a2a
4 Copyright (C) 1998 by Jacques Nomssi Nzali
5 For conditions of distribution and use, see copyright notice in readme.txt
15 {Byte = usigned char; 8 bits}
21 uInt
= cardinal; { 16 bits or more }
36 { a pointer to integer casting is used to do pointer arithmetic.
37 ptr2int must be an integer type and sizeof(ptr2int) must be less
38 than sizeof(pointer) - Nomssi }
41 zByteArray
= array[0..(MaxInt
div SizeOf(Bytef
))-1] of Bytef
;
42 pzByteArray
= ^zByteArray
;
44 zIntfArray
= array[0..(MaxInt
div SizeOf(Intf
))-1] of Intf
;
45 pzIntfArray
= ^zIntfArray
;
47 zuIntArray
= array[0..(MaxInt
div SizeOf(uInt
))-1] of uInt
;
48 PuIntArray
= ^zuIntArray
;
50 { Type declarations - only for deflate }
66 zuchfArray
= zByteArray
;
67 puchfArray
= ^zuchfArray
;
69 zushfArray
= array[0..(MaxInt
div SizeOf(ushf
))-1] of ushf
;
70 pushfArray
= ^zushfArray
;
72 procedure zmemcpy(destp
: pBytef
; sourcep
: pBytef
; len
: uInt
);
73 function zmemcmp(s1p
, s2p
: pBytef
; len
: uInt
) : int
;
74 procedure zmemzero(destp
: pBytef
; len
: uInt
);
75 procedure zcfree(opaque
: voidpf
; ptr
: voidpf
);
76 function zcalloc (opaque
: voidpf
; items
: uInt
; size
: uInt
) : voidpf
;
80 procedure zmemcpy(destp
: pBytef
; sourcep
: pBytef
; len
: uInt
);
82 Move(sourcep
^, destp
^, len
);
85 function zmemcmp(s1p
, s2p
: pBytef
; len
: uInt
) : int
;
93 for j
:= 0 to pred(len
) do
95 if (source
^ <> dest
^) then
97 zmemcmp
:= 2*Ord(source
^ > dest
^)-1;
106 procedure zmemzero(destp
: pBytef
; len
: uInt
);
108 FillChar(destp
^, len
, 0);
111 procedure zcfree(opaque
: voidpf
; ptr
: voidpf
);
123 {h :=} GlobalFreePtr(ptr);
132 Handle := GlobalHandle(LH(ptr).H); { HiWord(LongInt(ptr)) }
133 GlobalUnLock(Handle);
138 memsize := puIntf(ptr)^;
139 FreeMem(ptr, memsize+SizeOf(uInt));
141 FreeMem(ptr); { Delphi 2,3,4 }
151 function zcalloc (opaque
: voidpf
; items
: uInt
; size
: uInt
) : voidpf
;
159 memsize
:= uLong(items
) * size
;
162 p := GlobalAllocPtr(gmem_moveable, memsize);
165 p := dosAlloc(memsize);
168 GetMemHuge(p, memsize);
171 Handle := GlobalAlloc(HeapAllocFlags, memsize);
172 p := GlobalLock(Handle);
175 GetMem(p, memsize+SizeOf(uInt));
176 puIntf(p)^:= memsize;
179 GetMem(p, memsize); { Delphi: p := AllocMem(memsize); }