1

我正在将 ZLIB 直接编译到可执行文件中,并且正在 VS2010 - 64 位上编译,这个简单的程序总是挂起,有什么想法吗?更多信息如下:

调用堆栈:

zlibtest.exe!inflate(z_stream_s * strm, int flush) 第 607 行    

zlibtest.exe!uncompress(unsigned char * dest, unsigned long * destLen, const unsigned char * source, unsigned long sourceLen) 第 44 行

zlibtest.exe!main(int argc, char * * argv) 第 137 行

它挂在这里:

for (;;)
    switch (state->mode) {
    case HEAD:
        if (state->wrap == 0) {
            state->mode = TYPEDO;
            break;
        }
        **NEEDBITS(16);**

程序:

#include "zlib.h"

int main( int argc, char * argv[] )
{
    char * buffer = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
    ULONG buffer_size = strlen( buffer ) + 1;

    ULONG compressed_size = compressBound( buffer_size );
    BYTE * compressed_buffer = new BYTE[ compressed_size ];

    if ( Z_OK != compress2( compressed_buffer, &compressed_size, ( Bytef * ) buffer, buffer_size, Z_DEFAULT_COMPRESSION ) )
        printf( "Failed to compress." );

    ULONG uncompressed_size = buffer_size;
    BYTE * uncompressed_buffer = new BYTE[ uncompressed_size ];

    if ( Z_OK != uncompress( uncompressed_buffer, &uncompressed_size, compressed_buffer, compressed_size ) )
        printf( "Failed to uncompress" );

    printf( "Press <ENTER> to exit..." );
    std::cin.ignore();
}
4

0 回答 0