| 176 | } |
| 177 | |
| 178 | int ZEXPORT inflateInit2_(z_streamp strm, int windowBits, |
| 179 | const char *version, int stream_size) { |
| 180 | int ret; |
| 181 | struct inflate_state FAR *state; |
| 182 | |
| 183 | if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || |
| 184 | stream_size != (int)(sizeof(z_stream))) |
| 185 | return Z_VERSION_ERROR; |
| 186 | if (strm == Z_NULL) return Z_STREAM_ERROR; |
| 187 | strm->msg = Z_NULL; /* in case we return an error */ |
| 188 | if (strm->zalloc == (alloc_func)0) { |
| 189 | #ifdef Z_SOLO |
| 190 | return Z_STREAM_ERROR; |
| 191 | #else |
| 192 | strm->zalloc = zcalloc; |
| 193 | strm->opaque = (voidpf)0; |
| 194 | #endif |
| 195 | } |
| 196 | if (strm->zfree == (free_func)0) |
| 197 | #ifdef Z_SOLO |
| 198 | return Z_STREAM_ERROR; |
| 199 | #else |
| 200 | strm->zfree = zcfree; |
| 201 | #endif |
| 202 | state = (struct inflate_state FAR *) |
| 203 | ZALLOC(strm, 1, sizeof(struct inflate_state)); |
| 204 | if (state == Z_NULL) return Z_MEM_ERROR; |
| 205 | Tracev((stderr, "inflate: allocated\n")); |
| 206 | strm->state = (struct internal_state FAR *)state; |
| 207 | state->strm = strm; |
| 208 | state->window = Z_NULL; |
| 209 | state->mode = HEAD; /* to pass state test in inflateReset2() */ |
| 210 | ret = inflateReset2(strm, windowBits); |
| 211 | if (ret != Z_OK) { |
| 212 | ZFREE(strm, state); |
| 213 | strm->state = Z_NULL; |
| 214 | } |
| 215 | return ret; |
| 216 | } |
| 217 | |
| 218 | int ZEXPORT inflateInit_(z_streamp strm, const char *version, |
| 219 | int stream_size) { |
no test coverage detected