Coding using ezlib.h


z_stream z;
z.avail_in = 0;
z.next_out = (unsigned char*) outBuf->Ptr();
z.avail_out = outBuf->Length();

TInt read = 0;

for(;{
if(z.avail_in==0){
in.Read(inBuf->Des());
read = inBuf->Length();
z.avail_in = read;
z.next_in = (unsigned char*) inBuf->Ptr();
}
if ( z.avail_in == 0 )
break;
deflate( &z, Z_NO_FLUSH ); //i get an access violation error here.

TInt count = 1024 - z.avail_out;
if(count)
out.Write(outBuf->Des());
z.next_out = (unsigned char*) outBuf->Ptr();
z.avail_out = 1024;

}

can someone spot my mistake?? i get an access violation when i try to use deflate()

both inBuf & outBuf are of HBufC8*