// stdafx.h : include file for standard system include files, // or project specific include files that are used frequently, but // are changed infrequently // #pragma once #ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later. #define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows. #endif #include <stdio.h> #include <tchar.h> #include <stdlib.h> #include <string.h> #include "zlib.h" // TODO: reference additional headers your program requires here // ZlibTest.cpp : Defines the entry point for the console application. // #include "stdafx.h" #pragma comment(lib, "zlib1d.lib") typedef unsigned char Byte; /* 8 bits */ typedef unsigned int uInt; /* 16 bits or more */ typedef unsigned long uLong; /* 32 bits or more */ const char hello[] = "hello zlib!"; void test_compress(Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen) { int err; uLong len = (uLong)strlen(hello)+1; err = compress(compr, &comprLen, (const Bytef*)hello, len); strcpy((char *)uncompr, "garbage"); err = uncompress(uncompr, &uncomprLen, compr, comprLen); } int _tmain(int argc, _TCHAR* argv[]) { Byte *compr, *uncompr; uLong comprLen = 10000*sizeof(int); uLong uncomprLen = comprLen; compr = (Byte *)calloc((uInt)comprLen, 1); uncompr = (Byte *)calloc((uInt)uncomprLen, 1); if(compr == NULL || uncompr == NULL) { printf("out of memory"); return 1; } test_compress(compr, comprLen, uncompr, uncomprLen); free(compr); free(uncopmr); return 0; }