diff options
| author | Mark Adler <madler@alumni.caltech.edu> | 2025-05-16 21:58:02 -0700 |
|---|---|---|
| committer | Mark Adler <git@madler.net> | 2025-12-06 17:39:45 -0800 |
| commit | 3e8e4bb5b2ad0ecfb69b34b04e6b5cf1f3807217 (patch) | |
| tree | a42bc5de727919adacff678799d5dd8e61062db6 | |
| parent | d0fc110cc31a30132bf878a86cf530e83d34d974 (diff) | |
| download | zlib-3e8e4bb5b2ad0ecfb69b34b04e6b5cf1f3807217.tar.gz zlib-3e8e4bb5b2ad0ecfb69b34b04e6b5cf1f3807217.tar.bz2 zlib-3e8e4bb5b2ad0ecfb69b34b04e6b5cf1f3807217.zip | |
Clarify the use of inflateGetHeader().
| -rw-r--r-- | zlib.h | 30 |
1 files changed, 16 insertions, 14 deletions
| @@ -1076,20 +1076,22 @@ ZEXTERN int ZEXPORT inflateGetHeader(z_streamp strm, | |||
| 1076 | 1076 | ||
| 1077 | The text, time, xflags, and os fields are filled in with the gzip header | 1077 | The text, time, xflags, and os fields are filled in with the gzip header |
| 1078 | contents. hcrc is set to true if there is a header CRC. (The header CRC | 1078 | contents. hcrc is set to true if there is a header CRC. (The header CRC |
| 1079 | was valid if done is set to one.) If extra is not Z_NULL, then extra_max | 1079 | was valid if done is set to one.) The extra, name, and comment pointers |
| 1080 | contains the maximum number of bytes to write to extra. Once done is true, | 1080 | much each be either Z_NULL or point to space to store that information from |
| 1081 | extra_len contains the actual extra field length, and extra contains the | 1081 | the header. If extra is not Z_NULL, then extra_max contains the maximum |
| 1082 | extra field, or that field truncated if extra_max is less than extra_len. | 1082 | number of bytes that can be written to extra. Once done is true, extra_len |
| 1083 | If name is not Z_NULL, then up to name_max characters are written there, | 1083 | contains the actual extra field length, and extra contains the extra field, |
| 1084 | terminated with a zero unless the length is greater than name_max. If | 1084 | or that field truncated if extra_max is less than extra_len. If name is not |
| 1085 | comment is not Z_NULL, then up to comm_max characters are written there, | 1085 | Z_NULL, then up to name_max characters, including the terminating zero, are |
| 1086 | terminated with a zero unless the length is greater than comm_max. When any | 1086 | written there. If comment is not Z_NULL, then up to comm_max characters, |
| 1087 | of extra, name, or comment are not Z_NULL and the respective field is not | 1087 | including the terminating zero, are written there. The application can tell |
| 1088 | present in the header, then that field is set to Z_NULL to signal its | 1088 | that the name or comment did not fit in the provided space by the absence of |
| 1089 | absence. This allows the use of deflateSetHeader() with the returned | 1089 | a terminating zero. If any of extra, name, or comment are not present in |
| 1090 | structure to duplicate the header. However if those fields are set to | 1090 | the header, then that field's pointer is set to Z_NULL. This allows the use |
| 1091 | allocated memory, then the application will need to save those pointers | 1091 | of deflateSetHeader() with the returned structure to duplicate the header. |
| 1092 | elsewhere so that they can be eventually freed. | 1092 | Note that if those fields initially pointed to allocated memory, then the |
| 1093 | application will need to save them elsewhere so that they can be eventually | ||
| 1094 | freed. | ||
| 1093 | 1095 | ||
| 1094 | If inflateGetHeader is not used, then the header information is simply | 1096 | If inflateGetHeader is not used, then the header information is simply |
| 1095 | discarded. The header is always checked for validity, including the header | 1097 | discarded. The header is always checked for validity, including the header |
