| 1487 | } |
| 1488 | |
| 1489 | int mz_deflateInit2(mz_streamp pStream, int level, int method, int window_bits, |
| 1490 | int mem_level, int strategy) { |
| 1491 | tdefl_compressor *pComp; |
| 1492 | mz_uint comp_flags = |
| 1493 | TDEFL_COMPUTE_ADLER32 | |
| 1494 | tdefl_create_comp_flags_from_zip_params(level, window_bits, strategy); |
| 1495 | |
| 1496 | if (!pStream) |
| 1497 | return MZ_STREAM_ERROR; |
| 1498 | if ((method != MZ_DEFLATED) || ((mem_level < 1) || (mem_level > 9)) || |
| 1499 | ((window_bits != MZ_DEFAULT_WINDOW_BITS) && |
| 1500 | (-window_bits != MZ_DEFAULT_WINDOW_BITS))) |
| 1501 | return MZ_PARAM_ERROR; |
| 1502 | |
| 1503 | pStream->data_type = 0; |
| 1504 | pStream->adler = MZ_ADLER32_INIT; |
| 1505 | pStream->msg = NULL; |
| 1506 | pStream->reserved = 0; |
| 1507 | pStream->total_in = 0; |
| 1508 | pStream->total_out = 0; |
| 1509 | if (!pStream->zalloc) |
| 1510 | pStream->zalloc = def_alloc_func; |
| 1511 | if (!pStream->zfree) |
| 1512 | pStream->zfree = def_free_func; |
| 1513 | |
| 1514 | pComp = (tdefl_compressor *)pStream->zalloc(pStream->opaque, 1, |
| 1515 | sizeof(tdefl_compressor)); |
| 1516 | if (!pComp) |
| 1517 | return MZ_MEM_ERROR; |
| 1518 | |
| 1519 | pStream->state = (struct mz_internal_state *)pComp; |
| 1520 | |
| 1521 | if (tdefl_init(pComp, NULL, NULL, comp_flags) != TDEFL_STATUS_OKAY) { |
| 1522 | mz_deflateEnd(pStream); |
| 1523 | return MZ_PARAM_ERROR; |
| 1524 | } |
| 1525 | |
| 1526 | return MZ_OK; |
| 1527 | } |
| 1528 | |
| 1529 | int mz_deflateReset(mz_streamp pStream) { |
| 1530 | if ((!pStream) || (!pStream->state) || (!pStream->zalloc) || |
no test coverage detected