diff options
author | Phillip Lougher <phillip@lougher.demon.co.uk> | 2009-08-06 18:09:30 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-08-07 13:39:56 -0400 |
commit | daeb6b6fbe27049f465c48a7d0ee5555c3b84064 (patch) | |
tree | 3a53744300e0083f3cbf8f769780d971234e3f8a | |
parent | 9c8a8228d0827e0d91d28527209988f672f97d28 (diff) |
bzip2/lzma/gzip: fix comments describing decompressor API
Fix and improve comments in decompress/generic.h that describe the
decompressor API. Also remove an unused definition, and rename INBUF_LEN
in lib/decompress_inflate.c to conform to bzip2/lzma naming.
Signed-off-by: Phillip Lougher <phillip@lougher.demon.co.uk>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | include/linux/decompress/generic.h | 32 | ||||
-rw-r--r-- | lib/decompress_inflate.c | 8 |
2 files changed, 23 insertions, 17 deletions
diff --git a/include/linux/decompress/generic.h b/include/linux/decompress/generic.h index 6dfb856327b..0c7111a55a1 100644 --- a/include/linux/decompress/generic.h +++ b/include/linux/decompress/generic.h | |||
@@ -1,31 +1,37 @@ | |||
1 | #ifndef DECOMPRESS_GENERIC_H | 1 | #ifndef DECOMPRESS_GENERIC_H |
2 | #define DECOMPRESS_GENERIC_H | 2 | #define DECOMPRESS_GENERIC_H |
3 | 3 | ||
4 | /* Minimal chunksize to be read. | ||
5 | *Bzip2 prefers at least 4096 | ||
6 | *Lzma prefers 0x10000 */ | ||
7 | #define COMPR_IOBUF_SIZE 4096 | ||
8 | |||
9 | typedef int (*decompress_fn) (unsigned char *inbuf, int len, | 4 | typedef int (*decompress_fn) (unsigned char *inbuf, int len, |
10 | int(*fill)(void*, unsigned int), | 5 | int(*fill)(void*, unsigned int), |
11 | int(*writebb)(void*, unsigned int), | 6 | int(*flush)(void*, unsigned int), |
12 | unsigned char *output, | 7 | unsigned char *outbuf, |
13 | int *posp, | 8 | int *posp, |
14 | void(*error)(char *x)); | 9 | void(*error)(char *x)); |
15 | 10 | ||
16 | /* inbuf - input buffer | 11 | /* inbuf - input buffer |
17 | *len - len of pre-read data in inbuf | 12 | *len - len of pre-read data in inbuf |
18 | *fill - function to fill inbuf if empty | 13 | *fill - function to fill inbuf when empty |
19 | *writebb - function to write out outbug | 14 | *flush - function to write out outbuf |
15 | *outbuf - output buffer | ||
20 | *posp - if non-null, input position (number of bytes read) will be | 16 | *posp - if non-null, input position (number of bytes read) will be |
21 | * returned here | 17 | * returned here |
22 | * | 18 | * |
23 | *If len != 0, the inbuf is initialized (with as much data), and fill | 19 | *If len != 0, inbuf should contain all the necessary input data, and fill |
24 | *should not be called | 20 | *should be NULL |
25 | *If len = 0, the inbuf is allocated, but empty. Its size is IOBUF_SIZE | 21 | *If len = 0, inbuf can be NULL, in which case the decompressor will allocate |
26 | *fill should be called (repeatedly...) to read data, at most IOBUF_SIZE | 22 | *the input buffer. If inbuf != NULL it must be at least XXX_IOBUF_SIZE bytes. |
23 | *fill will be called (repeatedly...) to read data, at most XXX_IOBUF_SIZE | ||
24 | *bytes should be read per call. Replace XXX with the appropriate decompressor | ||
25 | *name, i.e. LZMA_IOBUF_SIZE. | ||
26 | * | ||
27 | *If flush = NULL, outbuf must be large enough to buffer all the expected | ||
28 | *output. If flush != NULL, the output buffer will be allocated by the | ||
29 | *decompressor (outbuf = NULL), and the flush function will be called to | ||
30 | *flush the output buffer at the appropriate time (decompressor and stream | ||
31 | *dependent). | ||
27 | */ | 32 | */ |
28 | 33 | ||
34 | |||
29 | /* Utility routine to detect the decompression method */ | 35 | /* Utility routine to detect the decompression method */ |
30 | decompress_fn decompress_method(const unsigned char *inbuf, int len, | 36 | decompress_fn decompress_method(const unsigned char *inbuf, int len, |
31 | const char **name); | 37 | const char **name); |
diff --git a/lib/decompress_inflate.c b/lib/decompress_inflate.c index e36b296fc9f..bfe605ac534 100644 --- a/lib/decompress_inflate.c +++ b/lib/decompress_inflate.c | |||
@@ -25,7 +25,7 @@ | |||
25 | #include <linux/decompress/mm.h> | 25 | #include <linux/decompress/mm.h> |
26 | #include <linux/slab.h> | 26 | #include <linux/slab.h> |
27 | 27 | ||
28 | #define INBUF_LEN (16*1024) | 28 | #define GZIP_IOBUF_SIZE (16*1024) |
29 | 29 | ||
30 | /* Included from initramfs et al code */ | 30 | /* Included from initramfs et al code */ |
31 | STATIC int INIT gunzip(unsigned char *buf, int len, | 31 | STATIC int INIT gunzip(unsigned char *buf, int len, |
@@ -55,7 +55,7 @@ STATIC int INIT gunzip(unsigned char *buf, int len, | |||
55 | if (buf) | 55 | if (buf) |
56 | zbuf = buf; | 56 | zbuf = buf; |
57 | else { | 57 | else { |
58 | zbuf = malloc(INBUF_LEN); | 58 | zbuf = malloc(GZIP_IOBUF_SIZE); |
59 | len = 0; | 59 | len = 0; |
60 | } | 60 | } |
61 | if (!zbuf) { | 61 | if (!zbuf) { |
@@ -77,7 +77,7 @@ STATIC int INIT gunzip(unsigned char *buf, int len, | |||
77 | } | 77 | } |
78 | 78 | ||
79 | if (len == 0) | 79 | if (len == 0) |
80 | len = fill(zbuf, INBUF_LEN); | 80 | len = fill(zbuf, GZIP_IOBUF_SIZE); |
81 | 81 | ||
82 | /* verify the gzip header */ | 82 | /* verify the gzip header */ |
83 | if (len < 10 || | 83 | if (len < 10 || |
@@ -113,7 +113,7 @@ STATIC int INIT gunzip(unsigned char *buf, int len, | |||
113 | while (rc == Z_OK) { | 113 | while (rc == Z_OK) { |
114 | if (strm->avail_in == 0) { | 114 | if (strm->avail_in == 0) { |
115 | /* TODO: handle case where both pos and fill are set */ | 115 | /* TODO: handle case where both pos and fill are set */ |
116 | len = fill(zbuf, INBUF_LEN); | 116 | len = fill(zbuf, GZIP_IOBUF_SIZE); |
117 | if (len < 0) { | 117 | if (len < 0) { |
118 | rc = -1; | 118 | rc = -1; |
119 | error("read error"); | 119 | error("read error"); |