Browse Source

* Kill zalloc, zfree fields and start conversion to standard getmem & freemem

git-svn-id: trunk@1850 -
daniel 19 years ago
parent
commit
c91b31f01c

+ 0 - 31
packages/base/paszlib/example.pas

@@ -195,9 +195,6 @@ var
   len : integer;
   len : integer;
 begin
 begin
   len := strlen(hello)+1;
   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);
   err := deflateInit(c_stream, Z_DEFAULT_COMPRESSION);
   CHECK_ERR(err, 'deflateInit');
   CHECK_ERR(err, 'deflateInit');
@@ -241,10 +238,6 @@ var
 begin
 begin
   strcopy(PChar(uncompr), 'garbage');
   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.next_in  := compr;
   d_stream.avail_in := 0;
   d_stream.avail_in := 0;
   d_stream.next_out := uncompr;
   d_stream.next_out := uncompr;
@@ -289,10 +282,6 @@ var
   c_stream : z_stream; { compression stream }
   c_stream : z_stream; { compression stream }
   err : integer;
   err : integer;
 begin
 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);
   err := deflateInit(c_stream, Z_BEST_SPEED);
   CHECK_ERR(err, 'deflateInit');
   CHECK_ERR(err, 'deflateInit');
 
 
@@ -349,10 +338,6 @@ var
 begin
 begin
   strcopy(PChar(uncompr), 'garbage');
   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.next_in  := compr;
   d_stream.avail_in := cardinal(comprLen);
   d_stream.avail_in := cardinal(comprLen);
 
 
@@ -394,10 +379,6 @@ var
 
 
 begin
 begin
   len := strlen(hello)+1;
   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);
   err := deflateInit(c_stream, Z_DEFAULT_COMPRESSION);
   CHECK_ERR(err, 'deflateInit');
   CHECK_ERR(err, 'deflateInit');
 
 
@@ -435,10 +416,6 @@ var
 begin
 begin
   strcopy(PChar(uncompr), 'garbage');
   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.next_in  := compr;
   d_stream.avail_in := 2; { just read the zlib header }
   d_stream.avail_in := 2; { just read the zlib header }
 
 
@@ -478,10 +455,6 @@ var
   c_stream : z_stream; { compression stream }
   c_stream : z_stream; { compression stream }
   err : integer;
   err : integer;
 begin
 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);
   err := deflateInit(c_stream, Z_BEST_COMPRESSION);
   CHECK_ERR(err, 'deflateInit');
   CHECK_ERR(err, 'deflateInit');
 
 
@@ -517,10 +490,6 @@ var
 begin
 begin
   strcopy(PChar(uncompr), 'garbage');
   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.next_in  := compr;
   d_stream.avail_in := cardinal(comprLen);
   d_stream.avail_in := cardinal(comprLen);
 
 

+ 0 - 3
packages/base/paszlib/gzio.pas

@@ -150,9 +150,6 @@ begin
   level := Z_DEFAULT_COMPRESSION;
   level := Z_DEFAULT_COMPRESSION;
   strategy := Z_DEFAULT_STRATEGY;
   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_in := nil;
   s^.stream.next_out := nil;
   s^.stream.next_out := nil;
   s^.stream.avail_in := 0;
   s^.stream.avail_in := 0;

+ 3 - 8
packages/base/paszlib/zbase.pas

@@ -291,10 +291,6 @@ type
     msg : string[255];         { last error message, '' if no error }
     msg : string[255];         { last error message, '' if no error }
     state : pInternal_state; { not visible by applications }
     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 }
     data_type : integer;      { best guess about the data type: ascii or binary }
     adler : cardinal;        { adler32 value of the uncompressed data }
     adler : cardinal;        { adler32 value of the uncompressed data }
     reserved : cardinal;     { reserved for future use }
     reserved : cardinal;     { reserved for future use }
@@ -506,18 +502,17 @@ end;
 
 
 function ZALLOC (var strm : z_stream; items : cardinal; size : cardinal) : pointer;
 function ZALLOC (var strm : z_stream; items : cardinal; size : cardinal) : pointer;
 begin
 begin
-  ZALLOC := strm.zalloc(strm.opaque, items, size);
+  getmem(ZALLOC,items*size);
 end;
 end;
 
 
 procedure ZFREE (var strm : z_stream; ptr : pointer);
 procedure ZFREE (var strm : z_stream; ptr : pointer);
 begin
 begin
-  strm.zfree(strm.opaque, ptr);
+  freemem(ptr);
 end;
 end;
 
 
 procedure TRY_FREE (var strm : z_stream; ptr : pointer);
 procedure TRY_FREE (var strm : z_stream; ptr : pointer);
 begin
 begin
-  {if @strm <> Z_NULL then}
-    strm.zfree(strm.opaque, ptr);
+  freemem(ptr);
 end;
 end;
 
 
 end.
 end.

+ 0 - 4
packages/base/paszlib/zcompres.pas

@@ -81,10 +81,6 @@ begin
     exit;
     exit;
   end;
   end;
 
 
-  stream.zalloc := NIL;       { alloc_func(0); }
-  stream.zfree := NIL;        { free_func(0); }
-  stream.opaque := NIL;       { voidpf(0); }
-
   err := deflateInit(stream, level);
   err := deflateInit(stream, level);
   if (err <> Z_OK) then
   if (err <> Z_OK) then
   begin
   begin

+ 2 - 10
packages/base/paszlib/zdeflate.pas

@@ -527,13 +527,6 @@ begin
   }
   }
   { SetLength(strm.msg, 255); }
   { SetLength(strm.msg, 255); }
   strm.msg := '';
   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
   if (level  =  Z_DEFAULT_COMPRESSION) then
     level := 6;
     level := 6;
@@ -555,7 +548,7 @@ begin
   end;
   end;
 
 
   s := deflate_state_ptr (ZALLOC(strm, 1, sizeof(deflate_state)));
   s := deflate_state_ptr (ZALLOC(strm, 1, sizeof(deflate_state)));
-  if (s = Z_NULL) then
+  if (s = nil) then
   begin
   begin
     deflateInit2_ := Z_MEM_ERROR;
     deflateInit2_ := Z_MEM_ERROR;
     exit;
     exit;
@@ -709,8 +702,7 @@ var
   s : deflate_state_ptr;
   s : deflate_state_ptr;
 begin
 begin
   if {(@strm = Z_NULL) or}
   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
   begin
     deflateReset := Z_STREAM_ERROR;
     deflateReset := Z_STREAM_ERROR;
     exit;
     exit;

+ 3 - 10
packages/base/paszlib/zinflate.pas

@@ -228,7 +228,7 @@ end;
 
 
 function inflateEnd(var z : z_stream) : integer;
 function inflateEnd(var z : z_stream) : integer;
 begin
 begin
-  if (z.state = Z_NULL) or not Assigned(z.zfree) then
+  if z.state=nil then
   begin
   begin
     inflateEnd :=  Z_STREAM_ERROR;
     inflateEnd :=  Z_STREAM_ERROR;
     exit;
     exit;
@@ -258,22 +258,15 @@ begin
   { initialize state }
   { initialize state }
   { SetLength(strm.msg, 255); }
   { SetLength(strm.msg, 255); }
   z.msg := '';
   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)) );
   z.state := pInternal_state( ZALLOC(z,1,sizeof(internal_state)) );
-  if (z.state = Z_NULL) then
+  if z.state=nil then
   begin
   begin
     inflateInit2_ := Z_MEM_ERROR;
     inflateInit2_ := Z_MEM_ERROR;
     exit;
     exit;
   end;
   end;
 
 
-  z.state^.blocks := Z_NULL;
+  z.state^.blocks := nil;
 
 
   { handle undocumented nowrap option (no zlib header or check) }
   { handle undocumented nowrap option (no zlib header or check) }
   z.state^.nowrap := FALSE;
   z.state^.nowrap := FALSE;

+ 0 - 3
packages/base/paszlib/zuncompr.pas

@@ -63,9 +63,6 @@ begin
     exit;
     exit;
   end;
   end;
 
 
-  stream.zalloc := nil;       { alloc_func(0); }
-  stream.zfree := nil;        { free_func(0); }
-
   err := inflateInit(stream);
   err := inflateInit(stream);
   if (err <> Z_OK) then
   if (err <> Z_OK) then
   begin
   begin