BZip2 c++ error

G

Geky

I'm trying to use BZip2 library but I receive always an access
violation error. I use two different codes:

bz_stream bzstream;
ZeroMemory(&bzstream, sizeof(bzstream));


bzstream.bzalloc=NULL;
bzstream.bzfree=NULL;
bzstream.opaque=NULL;


int x = BZ2_bzCompressInit(&bzstream, 5, 0, 30);


BZ2_bzCompressInit(&bzstream, 5, 0, 30); <-- HERE IT RETURN
THE ERROR


if I use "bz_stream* bzstream" in place of "bz_stream bzstream" my
compiler says that "local variable 'bzstream' used without having been
initialized" :-(.


+++++++++++++++++++++++++++++


char pOrig[256], pComp[256], pDec[256];
unsigned int OrigLen, CompLen, DecLen;


strcpy(pOrig, "OMFG PIE! OMFG PIE! OMFG PIE! OMFG PIE! OMFG
PIE! OMFG
PIE!OMFG PIE! OMFG PIE! OMFG PIE! OMFG PIE! OMFG PIE! OMFG PIE! OMFG
PIE! OMFG PIE! OMFG PIE! OMFG PIE! OMFG PIE! OMFG PIE! OMFG PIE! OMFG
PIE!");
OrigLen = strlen(pOrig) + 1;
printf("Original:\t%s\nOrig Len:\t%d\n\n", pOrig, OrigLen);


CompLen = 256;
BZ2_bzBuffToBuffCompress(pComp, &CompLen, pOrig, OrigLen, 9,
0, 30); <-- HERE THERE IS THE ERROR AGAIN


I can't understand why there is this access violation always here and
with two different codes

Anyone know how to use bzlib?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top