| 1657 | } inflate_state; |
| 1658 | |
| 1659 | int mz_inflateInit2(mz_streamp pStream, int window_bits) { |
| 1660 | inflate_state *pDecomp; |
| 1661 | if (!pStream) |
| 1662 | return MZ_STREAM_ERROR; |
| 1663 | if ((window_bits != MZ_DEFAULT_WINDOW_BITS) && |
| 1664 | (-window_bits != MZ_DEFAULT_WINDOW_BITS)) |
| 1665 | return MZ_PARAM_ERROR; |
| 1666 | |
| 1667 | pStream->data_type = 0; |
| 1668 | pStream->adler = 0; |
| 1669 | pStream->msg = NULL; |
| 1670 | pStream->total_in = 0; |
| 1671 | pStream->total_out = 0; |
| 1672 | pStream->reserved = 0; |
| 1673 | if (!pStream->zalloc) |
| 1674 | pStream->zalloc = def_alloc_func; |
| 1675 | if (!pStream->zfree) |
| 1676 | pStream->zfree = def_free_func; |
| 1677 | |
| 1678 | pDecomp = (inflate_state *)pStream->zalloc(pStream->opaque, 1, |
| 1679 | sizeof(inflate_state)); |
| 1680 | if (!pDecomp) |
| 1681 | return MZ_MEM_ERROR; |
| 1682 | |
| 1683 | pStream->state = (struct mz_internal_state *)pDecomp; |
| 1684 | |
| 1685 | tinfl_init(&pDecomp->m_decomp); |
| 1686 | pDecomp->m_dict_ofs = 0; |
| 1687 | pDecomp->m_dict_avail = 0; |
| 1688 | pDecomp->m_last_status = TINFL_STATUS_NEEDS_MORE_INPUT; |
| 1689 | pDecomp->m_first_call = 1; |
| 1690 | pDecomp->m_has_flushed = 0; |
| 1691 | pDecomp->m_window_bits = window_bits; |
| 1692 | |
| 1693 | return MZ_OK; |
| 1694 | } |
| 1695 | |
| 1696 | int mz_inflateInit(mz_streamp pStream) { |
| 1697 | return mz_inflateInit2(pStream, MZ_DEFAULT_WINDOW_BITS); |