On 3-jan-04, at 23:29, John Scott <[EMAIL PROTECTED]> wrote:


I want to use sqlite_encode_binary to encode zip files into sqlite databse. But somehow I don't get the wanted result of this procedure.
Can someone tell me where i made a mistake??


Encoding:

wxFFile *load_file = new wxFFile();
load_file->Open("pc.zip", "rb");
size_t size = load_file->Length();

char in[size];
unsigned long nLoadSize = load_file->Read((void *)in, size);
unsigned char out[2 +(257*nLoadSize)/254];
sqlite_encode_binary((const unsigned char*)in, 257*nLoadSize)/254, (unsigned char*)out);

This is actually real basic C.


Your problems are with allocating memory.
The following lines wont work as they are evaluated at compile time, not at runtime.


char in[size];
unsigned char out[2 +(257*nLoadSize)/254];

Instead you should use:


unsigned char* in = malloc( size );
unsigned char* out = malloc( 2 +(257*nLoadSize)/254 );

HTH,

- Rob Laveaux

--------------------------------------------------------
Pluggers Software
Thijssestraat 203
2521 ZG  Den Haag
The Netherlands

Email: [EMAIL PROTECTED]
Website: http://www.pluggers.nl

--------------------------------------------------------


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to