mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-29 05:40:01 +02:00
* Kill zalloc, zfree fields and start conversion to standard getmem & freemem
git-svn-id: trunk@1850 -
This commit is contained in:
parent
7b313df7d7
commit
c91b31f01c
@ -195,9 +195,6 @@ var
|
||||
len : integer;
|
||||
begin
|
||||
len := strlen(hello)+1;
|
||||
c_stream.zalloc := NIL; {alloc_func(0);}
|
||||
c_stream.zfree := NIL; {free_func(0);}
|
||||
c_stream.opaque := NIL; {voidpf(0);}
|
||||
|
||||
err := deflateInit(c_stream, Z_DEFAULT_COMPRESSION);
|
||||
CHECK_ERR(err, 'deflateInit');
|
||||
@ -241,10 +238,6 @@ var
|
||||
begin
|
||||
strcopy(PChar(uncompr), 'garbage');
|
||||
|
||||
d_stream.zalloc := NIL; {alloc_func(0);}
|
||||
d_stream.zfree := NIL; {free_func(0);}
|
||||
d_stream.opaque := NIL; {voidpf(0);}
|
||||
|
||||
d_stream.next_in := compr;
|
||||
d_stream.avail_in := 0;
|
||||
d_stream.next_out := uncompr;
|
||||
@ -289,10 +282,6 @@ var
|
||||
c_stream : z_stream; { compression stream }
|
||||
err : integer;
|
||||
begin
|
||||
c_stream.zalloc := NIL; {alloc_func(0);}
|
||||
c_stream.zfree := NIL; {free_func(0);}
|
||||
c_stream.opaque := NIL; {voidpf(0);}
|
||||
|
||||
err := deflateInit(c_stream, Z_BEST_SPEED);
|
||||
CHECK_ERR(err, 'deflateInit');
|
||||
|
||||
@ -349,10 +338,6 @@ var
|
||||
begin
|
||||
strcopy(PChar(uncompr), 'garbage');
|
||||
|
||||
d_stream.zalloc := NIL; {alloc_func(0);}
|
||||
d_stream.zfree := NIL; {free_func(0);}
|
||||
d_stream.opaque := NIL; {voidpf(0);}
|
||||
|
||||
d_stream.next_in := compr;
|
||||
d_stream.avail_in := cardinal(comprLen);
|
||||
|
||||
@ -394,10 +379,6 @@ var
|
||||
|
||||
begin
|
||||
len := strlen(hello)+1;
|
||||
c_stream.zalloc := NIL; {alloc_func(0);}
|
||||
c_stream.zfree := NIL; {free_func(0);}
|
||||
c_stream.opaque := NIL; {voidpf(0);}
|
||||
|
||||
err := deflateInit(c_stream, Z_DEFAULT_COMPRESSION);
|
||||
CHECK_ERR(err, 'deflateInit');
|
||||
|
||||
@ -435,10 +416,6 @@ var
|
||||
begin
|
||||
strcopy(PChar(uncompr), 'garbage');
|
||||
|
||||
d_stream.zalloc := NIL; {alloc_func(0);}
|
||||
d_stream.zfree := NIL; {free_func(0);}
|
||||
d_stream.opaque := NIL; {voidpf(0);}
|
||||
|
||||
d_stream.next_in := compr;
|
||||
d_stream.avail_in := 2; { just read the zlib header }
|
||||
|
||||
@ -478,10 +455,6 @@ var
|
||||
c_stream : z_stream; { compression stream }
|
||||
err : integer;
|
||||
begin
|
||||
c_stream.zalloc := NIL; {(alloc_func)0;}
|
||||
c_stream.zfree := NIL; {(free_func)0;}
|
||||
c_stream.opaque := NIL; {(voidpf)0;}
|
||||
|
||||
err := deflateInit(c_stream, Z_BEST_COMPRESSION);
|
||||
CHECK_ERR(err, 'deflateInit');
|
||||
|
||||
@ -517,10 +490,6 @@ var
|
||||
begin
|
||||
strcopy(PChar(uncompr), 'garbage');
|
||||
|
||||
d_stream.zalloc := NIL; { alloc_func(0); }
|
||||
d_stream.zfree := NIL; { free_func(0); }
|
||||
d_stream.opaque := NIL; { voidpf(0); }
|
||||
|
||||
d_stream.next_in := compr;
|
||||
d_stream.avail_in := cardinal(comprLen);
|
||||
|
||||
|
@ -150,9 +150,6 @@ begin
|
||||
level := Z_DEFAULT_COMPRESSION;
|
||||
strategy := Z_DEFAULT_STRATEGY;
|
||||
|
||||
s^.stream.zalloc := nil; { (alloc_func)0 }
|
||||
s^.stream.zfree := nil; { (free_func)0 }
|
||||
s^.stream.opaque := nil; { (voidpf)0 }
|
||||
s^.stream.next_in := nil;
|
||||
s^.stream.next_out := nil;
|
||||
s^.stream.avail_in := 0;
|
||||
|
@ -291,10 +291,6 @@ type
|
||||
msg : string[255]; { last error message, '' if no error }
|
||||
state : pInternal_state; { not visible by applications }
|
||||
|
||||
zalloc : alloc_func; { used to allocate the internal state }
|
||||
zfree : free_func; { used to free the internal state }
|
||||
opaque : pointer; { private data object passed to zalloc and zfree }
|
||||
|
||||
data_type : integer; { best guess about the data type: ascii or binary }
|
||||
adler : cardinal; { adler32 value of the uncompressed data }
|
||||
reserved : cardinal; { reserved for future use }
|
||||
@ -506,18 +502,17 @@ end;
|
||||
|
||||
function ZALLOC (var strm : z_stream; items : cardinal; size : cardinal) : pointer;
|
||||
begin
|
||||
ZALLOC := strm.zalloc(strm.opaque, items, size);
|
||||
getmem(ZALLOC,items*size);
|
||||
end;
|
||||
|
||||
procedure ZFREE (var strm : z_stream; ptr : pointer);
|
||||
begin
|
||||
strm.zfree(strm.opaque, ptr);
|
||||
freemem(ptr);
|
||||
end;
|
||||
|
||||
procedure TRY_FREE (var strm : z_stream; ptr : pointer);
|
||||
begin
|
||||
{if @strm <> Z_NULL then}
|
||||
strm.zfree(strm.opaque, ptr);
|
||||
freemem(ptr);
|
||||
end;
|
||||
|
||||
end.
|
@ -81,10 +81,6 @@ begin
|
||||
exit;
|
||||
end;
|
||||
|
||||
stream.zalloc := NIL; { alloc_func(0); }
|
||||
stream.zfree := NIL; { free_func(0); }
|
||||
stream.opaque := NIL; { voidpf(0); }
|
||||
|
||||
err := deflateInit(stream, level);
|
||||
if (err <> Z_OK) then
|
||||
begin
|
||||
|
@ -527,13 +527,6 @@ begin
|
||||
}
|
||||
{ SetLength(strm.msg, 255); }
|
||||
strm.msg := '';
|
||||
if strm.zalloc=nil then
|
||||
begin
|
||||
strm.zalloc := @zcalloc;
|
||||
strm.opaque := nil;
|
||||
end;
|
||||
if strm.zfree=nil then
|
||||
strm.zfree := @zcfree;
|
||||
|
||||
if (level = Z_DEFAULT_COMPRESSION) then
|
||||
level := 6;
|
||||
@ -555,7 +548,7 @@ begin
|
||||
end;
|
||||
|
||||
s := deflate_state_ptr (ZALLOC(strm, 1, sizeof(deflate_state)));
|
||||
if (s = Z_NULL) then
|
||||
if (s = nil) then
|
||||
begin
|
||||
deflateInit2_ := Z_MEM_ERROR;
|
||||
exit;
|
||||
@ -709,8 +702,7 @@ var
|
||||
s : deflate_state_ptr;
|
||||
begin
|
||||
if {(@strm = Z_NULL) or}
|
||||
(strm.state = Z_NULL)
|
||||
or (not Assigned(strm.zalloc)) or (not Assigned(strm.zfree)) then
|
||||
(strm.state = nil) then
|
||||
begin
|
||||
deflateReset := Z_STREAM_ERROR;
|
||||
exit;
|
||||
|
@ -228,7 +228,7 @@ end;
|
||||
|
||||
function inflateEnd(var z : z_stream) : integer;
|
||||
begin
|
||||
if (z.state = Z_NULL) or not Assigned(z.zfree) then
|
||||
if z.state=nil then
|
||||
begin
|
||||
inflateEnd := Z_STREAM_ERROR;
|
||||
exit;
|
||||
@ -258,22 +258,15 @@ begin
|
||||
{ initialize state }
|
||||
{ SetLength(strm.msg, 255); }
|
||||
z.msg := '';
|
||||
if z.zalloc=nil then
|
||||
begin
|
||||
z.zalloc := @zcalloc;
|
||||
z.opaque := nil;
|
||||
end;
|
||||
if z.zfree=nil then
|
||||
z.zfree := @zcfree;
|
||||
|
||||
z.state := pInternal_state( ZALLOC(z,1,sizeof(internal_state)) );
|
||||
if (z.state = Z_NULL) then
|
||||
if z.state=nil then
|
||||
begin
|
||||
inflateInit2_ := Z_MEM_ERROR;
|
||||
exit;
|
||||
end;
|
||||
|
||||
z.state^.blocks := Z_NULL;
|
||||
z.state^.blocks := nil;
|
||||
|
||||
{ handle undocumented nowrap option (no zlib header or check) }
|
||||
z.state^.nowrap := FALSE;
|
||||
|
@ -63,9 +63,6 @@ begin
|
||||
exit;
|
||||
end;
|
||||
|
||||
stream.zalloc := nil; { alloc_func(0); }
|
||||
stream.zfree := nil; { free_func(0); }
|
||||
|
||||
err := inflateInit(stream);
|
||||
if (err <> Z_OK) then
|
||||
begin
|
||||
|
Loading…
Reference in New Issue
Block a user