Tuesday, December 28, 2010

How to split and join array in C++?

Programmer Question

I have a byte array like this:



lzo_bytep out; // my byte array
size_t uncompressedImageSize = 921600;

out = (lzo_bytep) malloc((uncompressedImageSize + uncompressedImageSize / 16 + 64 + 3));
wrkmem = (lzo_voidp) malloc(LZO1X_1_MEM_COMPRESS);

// Now the byte array has 802270 bytes
r = lzo1x_1_compress(imageData, uncompressedImageSize, out, &out_len, wrkmem);


How can I split it into smaller parts under 65,535 bytes (the byte array is one large packet which I want to sent over UDP which has upper limit 65,535 bytes) and then join those small chunks back into a continuous array?



Find the answer here

No comments:

Post a Comment

LinkWithin

Related Posts with Thumbnails