From: Amit Kalekar [mailto:[EMAIL PROTECTED]] > unsigned long complen = (unsigned long)51 * (unsigned long)120 / > (unsigned long)100 + (unsigned long)12; > Bytef* compbuf = new Bytef[complen];
Allocating a plenty big output buffer, good. > MemSet(compbuf, 0x00, complen); As Martin Elzen pointed out, this call is bad since MemSet is backwards from standard memset. But you don't need to zero the output buffer anyway so this is not your problem. (Just remove this call.) > char * packet = (char *)"Select CustomerName, CustomerID from customers"; The length of this string is 46 bytes plus the terminator, not the 51 hard coded in the call below. Suggest you use StrLen for this. > int nRet = ZLibcompress2 ( ZLibRef, (Bytef*) compbuf, > (unsigned long*) complen, // <<----- ??? > (Bytef*) packet, > (unsigned long) 51, > Z_DEFAULT_COMPRESSION ); The parameter flagged above is wrong -- ZLibcompress2 takes an (unsigned long*) but you are passing an (unsigned long) instead. The unnecessary cast is actually masking the error. (There are several other unnecessary casts in this code too.) Just pass &complen. You must pass the address of complen since this is an in/out parameter. On input it tells zlib how big the output buffer is, and on output it tells you how many bytes of output there actually are. -slj- -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
