Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
999f677f
Commit
999f677f
authored
May 27, 2003
by
Linus Torvalds
Committed by
Russell King
May 27, 2003
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make zlib_inflate look more like ANSI C code.
Anybody who still thinks K&R makes sense should just be shot.
parent
cca66bf2
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
124 additions
and
98 deletions
+124
-98
lib/zlib_inflate/infblock.c
lib/zlib_inflate/infblock.c
+27
-21
lib/zlib_inflate/infcodes.c
lib/zlib_inflate/infcodes.c
+16
-12
lib/zlib_inflate/inffast.c
lib/zlib_inflate/inffast.c
+8
-6
lib/zlib_inflate/inflate.c
lib/zlib_inflate/inflate.c
+31
-22
lib/zlib_inflate/inftrees.c
lib/zlib_inflate/inftrees.c
+37
-33
lib/zlib_inflate/infutil.c
lib/zlib_inflate/infutil.c
+5
-4
No files found.
lib/zlib_inflate/infblock.c
View file @
999f677f
...
...
@@ -65,10 +65,11 @@ local const uInt border[] = { /* Order of the bit length code lengths */
*/
void
zlib_inflate_blocks_reset
(
s
,
z
,
c
)
inflate_blocks_statef
*
s
;
z_streamp
z
;
uLongf
*
c
;
void
zlib_inflate_blocks_reset
(
inflate_blocks_statef
*
s
,
z_streamp
z
,
uLongf
*
c
)
{
if
(
c
!=
Z_NULL
)
*
c
=
s
->
check
;
...
...
@@ -82,10 +83,11 @@ uLongf *c;
z
->
adler
=
s
->
check
=
(
*
s
->
checkfn
)(
0L
,
(
const
Bytef
*
)
Z_NULL
,
0
);
}
inflate_blocks_statef
*
zlib_inflate_blocks_new
(
z
,
c
,
w
)
z_streamp
z
;
check_func
c
;
uInt
w
;
inflate_blocks_statef
*
zlib_inflate_blocks_new
(
z_streamp
z
,
check_func
c
,
uInt
w
)
{
inflate_blocks_statef
*
s
;
...
...
@@ -100,10 +102,11 @@ uInt w;
}
int
zlib_inflate_blocks
(
s
,
z
,
r
)
inflate_blocks_statef
*
s
;
z_streamp
z
;
int
r
;
int
zlib_inflate_blocks
(
inflate_blocks_statef
*
s
,
z_streamp
z
,
int
r
)
{
uInt
t
;
/* temporary storage */
uLong
b
;
/* bit buffer */
...
...
@@ -325,19 +328,21 @@ int r;
}
int
zlib_inflate_blocks_free
(
s
,
z
)
inflate_blocks_statef
*
s
;
z_streamp
z
;
int
zlib_inflate_blocks_free
(
inflate_blocks_statef
*
s
,
z_streamp
z
)
{
zlib_inflate_blocks_reset
(
s
,
z
,
Z_NULL
);
return
Z_OK
;
}
void
zlib_inflate_set_dictionary
(
s
,
d
,
n
)
inflate_blocks_statef
*
s
;
const
Bytef
*
d
;
uInt
n
;
void
zlib_inflate_set_dictionary
(
inflate_blocks_statef
*
s
,
const
Bytef
*
d
,
uInt
n
)
{
memcpy
(
s
->
window
,
d
,
n
);
s
->
read
=
s
->
write
=
s
->
window
+
n
;
...
...
@@ -348,8 +353,9 @@ uInt n;
* by Z_SYNC_FLUSH or Z_FULL_FLUSH.
* IN assertion: s != Z_NULL
*/
int
zlib_inflate_blocks_sync_point
(
s
)
inflate_blocks_statef
*
s
;
int
zlib_inflate_blocks_sync_point
(
inflate_blocks_statef
*
s
)
{
return
s
->
mode
==
LENS
;
}
lib/zlib_inflate/infcodes.c
View file @
999f677f
...
...
@@ -14,11 +14,13 @@
#define exop word.what.Exop
#define bits word.what.Bits
inflate_codes_statef
*
zlib_inflate_codes_new
(
bl
,
bd
,
tl
,
td
,
z
)
uInt
bl
,
bd
;
inflate_huft
*
tl
;
inflate_huft
*
td
;
/* need separate declaration for Borland C++ */
z_streamp
z
;
inflate_codes_statef
*
zlib_inflate_codes_new
(
uInt
bl
,
uInt
bd
,
inflate_huft
*
tl
,
inflate_huft
*
td
,
/* need separate declaration for Borland C++ */
z_streamp
z
)
{
inflate_codes_statef
*
c
;
...
...
@@ -34,10 +36,11 @@ z_streamp z;
}
int
zlib_inflate_codes
(
s
,
z
,
r
)
inflate_blocks_statef
*
s
;
z_streamp
z
;
int
r
;
int
zlib_inflate_codes
(
inflate_blocks_statef
*
s
,
z_streamp
z
,
int
r
)
{
uInt
j
;
/* temporary storage */
inflate_huft
*
t
;
/* temporary pointer */
...
...
@@ -197,8 +200,9 @@ int r;
}
void
zlib_inflate_codes_free
(
c
,
z
)
inflate_codes_statef
*
c
;
z_streamp
z
;
void
zlib_inflate_codes_free
(
inflate_codes_statef
*
c
,
z_streamp
z
)
{
}
lib/zlib_inflate/inffast.c
View file @
999f677f
...
...
@@ -25,12 +25,14 @@ struct inflate_codes_state;
at least ten. The ten bytes are six bytes for the longest length/
distance pair plus four bytes for overloading the bit buffer. */
int
zlib_inflate_fast
(
bl
,
bd
,
tl
,
td
,
s
,
z
)
uInt
bl
,
bd
;
inflate_huft
*
tl
;
inflate_huft
*
td
;
/* need separate declaration for Borland C++ */
inflate_blocks_statef
*
s
;
z_streamp
z
;
int
zlib_inflate_fast
(
uInt
bl
,
uInt
bd
,
inflate_huft
*
tl
,
inflate_huft
*
td
,
/* need separate declaration for Borland C++ */
inflate_blocks_statef
*
s
,
z_streamp
z
)
{
inflate_huft
*
t
;
/* temporary pointer */
uInt
e
;
/* extra bits or operation */
...
...
lib/zlib_inflate/inflate.c
View file @
999f677f
...
...
@@ -14,8 +14,9 @@ int ZEXPORT zlib_inflate_workspacesize(void)
}
int
ZEXPORT
zlib_inflateReset
(
z
)
z_streamp
z
;
int
ZEXPORT
zlib_inflateReset
(
z_streamp
z
)
{
if
(
z
==
Z_NULL
||
z
->
state
==
Z_NULL
||
z
->
workspace
==
Z_NULL
)
return
Z_STREAM_ERROR
;
...
...
@@ -27,8 +28,9 @@ z_streamp z;
}
int
ZEXPORT
zlib_inflateEnd
(
z
)
z_streamp
z
;
int
ZEXPORT
zlib_inflateEnd
(
z_streamp
z
)
{
if
(
z
==
Z_NULL
||
z
->
state
==
Z_NULL
||
z
->
workspace
==
Z_NULL
)
return
Z_STREAM_ERROR
;
...
...
@@ -39,11 +41,12 @@ z_streamp z;
}
int
ZEXPORT
zlib_inflateInit2_
(
z
,
w
,
version
,
stream_size
)
z_streamp
z
;
int
w
;
const
char
*
version
;
int
stream_size
;
int
ZEXPORT
zlib_inflateInit2_
(
z_streamp
z
,
int
w
,
const
char
*
version
,
int
stream_size
)
{
if
(
version
==
Z_NULL
||
version
[
0
]
!=
ZLIB_VERSION
[
0
]
||
stream_size
!=
sizeof
(
z_stream
)
||
z
->
workspace
==
Z_NULL
)
...
...
@@ -100,10 +103,11 @@ static int zlib_inflate_packet_flush(inflate_blocks_statef *s)
}
int
ZEXPORT
zlib_inflateInit_
(
z
,
version
,
stream_size
)
z_streamp
z
;
const
char
*
version
;
int
stream_size
;
int
ZEXPORT
zlib_inflateInit_
(
z_streamp
z
,
const
char
*
version
,
int
stream_size
)
{
return
zlib_inflateInit2_
(
z
,
DEF_WBITS
,
version
,
stream_size
);
}
...
...
@@ -113,9 +117,10 @@ int stream_size;
#define NEEDBYTE {if(z->avail_in==0)goto empty;r=trv;}
#define NEXTBYTE (z->avail_in--,z->total_in++,*z->next_in++)
int
ZEXPORT
zlib_inflate
(
z
,
f
)
z_streamp
z
;
int
f
;
int
ZEXPORT
zlib_inflate
(
z_streamp
z
,
int
f
)
{
int
r
,
trv
;
uInt
b
;
...
...
@@ -245,8 +250,9 @@ int f;
}
int
ZEXPORT
zlib_inflateSync
(
z
)
z_streamp
z
;
int
ZEXPORT
zlib_inflateSync
(
z_streamp
z
)
{
uInt
n
;
/* number of bytes to look at */
Bytef
*
p
;
/* pointer to bytes */
...
...
@@ -303,8 +309,9 @@ z_streamp z;
* decompressing, PPP checks that at the end of input packet, inflate is
* waiting for these length bytes.
*/
int
ZEXPORT
zlib_inflateSyncPoint
(
z
)
z_streamp
z
;
int
ZEXPORT
zlib_inflateSyncPoint
(
z_streamp
z
)
{
if
(
z
==
Z_NULL
||
z
->
state
==
Z_NULL
||
z
->
state
->
blocks
==
Z_NULL
)
return
Z_STREAM_ERROR
;
...
...
@@ -373,8 +380,10 @@ static int zlib_inflate_addhistory(inflate_blocks_statef *s,
* will have been updated if need be.
*/
int
ZEXPORT
zlib_inflateIncomp
(
z
)
z_stream
*
z
;
int
ZEXPORT
zlib_inflateIncomp
(
z_stream
*
z
)
{
if
(
z
->
state
->
mode
!=
BLOCKS
)
return
Z_DATA_ERROR
;
...
...
lib/zlib_inflate/inftrees.c
View file @
999f677f
...
...
@@ -87,17 +87,18 @@ local const uInt cpdext[30] = { /* Extra bits for distance codes */
/* If BMAX needs to be larger than 16, then h and x[] should be uLong. */
#define BMAX 15
/* maximum bit length of any code */
local
int
huft_build
(
b
,
n
,
s
,
d
,
e
,
t
,
m
,
hp
,
hn
,
v
)
uIntf
*
b
;
/* code lengths in bits (all assumed <= BMAX) */
uInt
n
;
/* number of codes (assumed <= 288) */
uInt
s
;
/* number of simple-valued codes (0..s-1) */
const
uIntf
*
d
;
/* list of base values for non-simple codes */
const
uIntf
*
e
;
/* list of extra bits for non-simple codes */
inflate_huft
*
FAR
*
t
;
/* result: starting table */
uIntf
*
m
;
/* maximum lookup bits, returns actual */
inflate_huft
*
hp
;
/* space for trees */
uInt
*
hn
;
/* hufts used in space */
uIntf
*
v
;
/* working area: values in order of bit length */
local
int
huft_build
(
uIntf
*
b
,
/* code lengths in bits (all assumed <= BMAX) */
uInt
n
,
/* number of codes (assumed <= 288) */
uInt
s
,
/* number of simple-valued codes (0..s-1) */
const
uIntf
*
d
,
/* list of base values for non-simple codes */
const
uIntf
*
e
,
/* list of extra bits for non-simple codes */
inflate_huft
*
FAR
*
t
,
/* result: starting table */
uIntf
*
m
,
/* maximum lookup bits, returns actual */
inflate_huft
*
hp
,
/* space for trees */
uInt
*
hn
,
/* hufts used in space */
uIntf
*
v
/* working area: values in order of bit length */
)
/* Given a list of code lengths and a maximum table size, make a set of
tables to decode that set of codes. Return Z_OK on success, Z_BUF_ERROR
if the given code set is incomplete (the tables are still built in this
...
...
@@ -288,12 +289,13 @@ uIntf *v; /* working area: values in order of bit length */
}
int
zlib_inflate_trees_bits
(
c
,
bb
,
tb
,
hp
,
z
)
uIntf
*
c
;
/* 19 code lengths */
uIntf
*
bb
;
/* bits tree desired/actual depth */
inflate_huft
*
FAR
*
tb
;
/* bits tree result */
inflate_huft
*
hp
;
/* space for trees */
z_streamp
z
;
/* for messages */
int
zlib_inflate_trees_bits
(
uIntf
*
c
,
/* 19 code lengths */
uIntf
*
bb
,
/* bits tree desired/actual depth */
inflate_huft
*
FAR
*
tb
,
/* bits tree result */
inflate_huft
*
hp
,
/* space for trees */
z_streamp
z
/* for messages */
)
{
int
r
;
uInt
hn
=
0
;
/* hufts used in space */
...
...
@@ -312,16 +314,17 @@ z_streamp z; /* for messages */
return
r
;
}
int
zlib_inflate_trees_dynamic
(
nl
,
nd
,
c
,
bl
,
bd
,
tl
,
td
,
hp
,
z
)
uInt
nl
;
/* number of literal/length codes */
uInt
nd
;
/* number of distance codes */
uIntf
*
c
;
/* that many (total) code lengths */
uIntf
*
bl
;
/* literal desired/actual bit depth */
uIntf
*
bd
;
/* distance desired/actual bit depth */
inflate_huft
*
FAR
*
tl
;
/* literal/length tree result */
inflate_huft
*
FAR
*
td
;
/* distance tree result */
inflate_huft
*
hp
;
/* space for trees */
z_streamp
z
;
/* for messages */
int
zlib_inflate_trees_dynamic
(
uInt
nl
,
/* number of literal/length codes */
uInt
nd
,
/* number of distance codes */
uIntf
*
c
,
/* that many (total) code lengths */
uIntf
*
bl
,
/* literal desired/actual bit depth */
uIntf
*
bd
,
/* distance desired/actual bit depth */
inflate_huft
*
FAR
*
tl
,
/* literal/length tree result */
inflate_huft
*
FAR
*
td
,
/* distance tree result */
inflate_huft
*
hp
,
/* space for trees */
z_streamp
z
/* for messages */
)
{
int
r
;
uInt
hn
=
0
;
/* hufts used in space */
...
...
@@ -376,12 +379,13 @@ z_streamp z; /* for messages */
#include "inffixed.h"
int
zlib_inflate_trees_fixed
(
bl
,
bd
,
tl
,
td
,
z
)
uIntf
*
bl
;
/* literal desired/actual bit depth */
uIntf
*
bd
;
/* distance desired/actual bit depth */
inflate_huft
*
FAR
*
tl
;
/* literal/length tree result */
inflate_huft
*
FAR
*
td
;
/* distance tree result */
z_streamp
z
;
/* for memory allocation */
int
zlib_inflate_trees_fixed
(
uIntf
*
bl
,
/* literal desired/actual bit depth */
uIntf
*
bd
,
/* distance desired/actual bit depth */
inflate_huft
*
FAR
*
tl
,
/* literal/length tree result */
inflate_huft
*
FAR
*
td
,
/* distance tree result */
z_streamp
z
/* for memory allocation */
)
{
*
bl
=
fixed_bl
;
*
bd
=
fixed_bd
;
...
...
lib/zlib_inflate/infutil.c
View file @
999f677f
...
...
@@ -20,10 +20,11 @@ uInt zlib_inflate_mask[17] = {
/* copy as much as possible from the sliding window to the output area */
int
zlib_inflate_flush
(
s
,
z
,
r
)
inflate_blocks_statef
*
s
;
z_streamp
z
;
int
r
;
int
zlib_inflate_flush
(
inflate_blocks_statef
*
s
,
z_streamp
z
,
int
r
)
{
uInt
n
;
Bytef
*
p
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment