Skip to contentSkip to conversation

Trying to use zlib with openvpn

Openvpn-devel Ming-Ching Tiew 3 participants 4 messages May 26, 2004 – May 27, 2004

lore
Share & tools
lore
#0 lore raw

Last night after posting to openvpn-user maillist about wanting to use zlib with OpenVPN, I had a look at the code. It seems the compression code is well-contained in lzo.c, I could even do a one-to-one swap of 'LZO_COMPRESS' with zlib's 'compress' and similarly for decompress. It get compiled and linked. I was quite glad about that !!!

But of course, it is not so simple, it ran and crashed with segmentation fault. I now suspect the decompression memory allocation is not big enough. Any clues where else I should look at ?

#1 lore raw
Quoted 9 lines · Ming-Ching Tiew

Last night after posting to openvpn-user maillist about wanting to use zlib with OpenVPN, I had a look at the code. It seems the compression code is well-contained in lzo.c, I could even do a one-to-one swap of 'LZO_COMPRESS' with zlib's 'compress' and similarly for decompress. It get compiled and linked. I was quite glad about that !!!

Quoted 4 lines

But of course, it is not so simple, it ran and crashed with segmentation fault. I now suspect the decompression memory allocation is not big enough. Any clues where else I should look at ?

Make sure that you define

#define LZO_EXTRA_BUFFER(len) ((len)/64 + 16 + 3) /* LZO worst case size
expansion. */

for zlib.

James

#2 lore raw
Quoted 4 lines

Make sure that you define

#define LZO_EXTRA_BUFFER(len) ((len)/64 + 16 + 3) /* LZO worst case

size

Quoted 4 lines

expansion. */

for zlib.

OK thanks for the response. Upon closer investigation, I found that it is my own problem. The LZO_COMPRESS is taking the parameters as (source, source_len, dst, dest_len) whereas zlib compress is (dest, dest_len, source, source_len).

Therefore I just turned them around. It is now working !!!

My next question is whether anyone has a comparison of LZO and zlib in terms of relative time taken to compress. In addition, the zlib compress2() has a compression level parameter, I would also need to know how it fairs comparing with compress().

Thanks once again.

#3 lore raw
Quoted 11 lines · Ming-Ching Tiew

OK thanks for the response. Upon closer investigation, I found that it is my own problem. The LZO_COMPRESS is taking the parameters as (source, source_len, dst, dest_len) whereas zlib compress is (dest, dest_len, source, source_len).

Therefore I just turned them around. It is now working !!!

My next question is whether anyone has a comparison of LZO and zlib in terms of relative time taken to compress. In addition, the zlib compress2() has a compression level parameter, I would also need to know how it fairs comparing with compress().

I don't have a URL at hand and no time to search, try looking for "archive shootout" or "archiver shootout" in the web (Google perhaps) and at the LZO home page. LZO boasts its speed, and the LZO home page might have figures.

HTH,
Matthias