다른 zlib 버전 (1.2.7)
inflateInit2()가 주석 처리 된 이유를 모르겠습니다. inflateInit2하면 다음과 같은 작업을 수행 할 수 호출하지 않고
:
err = inflateInit(&d_stream);
err = inflateReset2(&d_stream, 31);
inflateReset2도 inflateInit에 의해 호출됩니다. inflateInit 내부에 WindowBits가 15 (1111 바이너리)로 설정됩니다. 하지만 gzip을 작동 시키려면 31 (11111)로 설정해야합니다.
이유는 여기에있다 :
inflateReset2 내부 다음이 수행된다 : 창 비트 15 (1,111 진수)로 설정하는 경우는 2 윈도우 비트가 설정되는 경우 1로 연결
wrap = (windowBits >> 4) + 1;
이제 HEAD 상태에서 다음 줄은 gzip을
if ((state->wrap & 2) && hold == 0x8b1f) { /* gzip header */
01을위한 매직 넘버와 함께 상태 -> 랩 값을 확인) (팽창 호출하는 경우 (31) (11111)
23,516,
그래서 다음 코드 나 메모리의 gzip 압축 해제를 할 수 있었다 : (참고 :이 코드는 압축 해제 할 수있는 완전한 데이터가 메모리 및 압축 해제 된 데이터에 대한 버퍼 크기가 충분 있다는 것을 가정)
int err;
z_stream d_stream; // decompression stream
d_stream.zalloc = (alloc_func)0;
d_stream.zfree = (free_func)0;
d_stream.opaque = (voidpf)0;
d_stream.next_in = deflated; // where deflated is a pointer the the compressed data buffer
d_stream.avail_in = deflatedLen; // where deflatedLen is the length of the compressed data
d_stream.next_out = inflated; // where inflated is a pointer to the resulting uncompressed data buffer
d_stream.avail_out = inflatedLen; // where inflatedLen is the size of the uncompressed data buffer
err = inflateInit(&d_stream);
err = inflateReset2(&d_stream, 31);
err = inflateEnd(&d_stream);
inflateInit2()에 주석을다는 것은 oder 솔루션입니다. 여기 WindowBits를 직접 설정할 수 있습니다
버전 1.1.3을 사용하려는 특별한 이유가 있습니까? 버전 1.1.4는 2002 년 3 월에 출시되었으며 최신 버전은 1.2.5입니다. – ruakh
사용하고있는 버전이 꽤 오래되었다는 것을 알고 있습니다. 그러나 이것은 zlib의 업데이트를 허용하지 않는 레거시 프로젝트입니다. – gmletzkojr