Trying to use zlib with openvpn
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 ?
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
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.
Quoted 11 lines · Ming-Ching Tiew
OK thanks for the response. Upon closer investigation, I found that it is my own problem. The
LZO_COMPRESSis 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 withcompress().
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