Subject: | Differences between bundled library and the current version? |
Hi,
I'm trying to package this library for Fedora. In order to do so, i need to remove the bundled c library and rely on the Fedora provided version of snappy (v1.1.0).
The only way i could get that to work was with the attached patch.
Could you check this out and let me know if this is the correct way to unbundle your version of the snappy library for Fedora ?
Any suggestions/explanations you might have to explain the differences would be most welcome.
Cheers
Dave
Subject: | compress_snappy_unbundle.patch |
diff -Naur old/Makefile.PL new/Makefile.PL
--- old/Makefile.PL 2013-10-13 18:26:49.000000000 +1100
+++ new/Makefile.PL 2014-08-23 14:18:22.085946140 +1000
@@ -31,6 +31,8 @@
},
DEFINE => $ctz,
+ LIBS => '-lsnappy',
+
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
clean => { FILES => 'Compress-Snappy-*' },
diff -Naur old/Snappy.xs new/Snappy.xs
--- old/Snappy.xs 2012-09-09 03:23:49.000000000 +1000
+++ new/Snappy.xs 2014-08-23 15:37:46.416968105 +1000
@@ -7,8 +7,7 @@
#define NEED_sv_2pvbyte
#include "ppport.h"
-#include "src/csnappy_compress.c"
-#include "src/csnappy_decompress.c"
+#include <snappy-c.h>
MODULE = Compress::Snappy PACKAGE = Compress::Snappy
@@ -20,8 +19,7 @@
PREINIT:
char *src, *dest;
STRLEN src_len;
- uint32_t dest_len;
- void *working_memory;
+ size_t dest_len;
CODE:
if (SvROK(sv) && ! SvAMAGIC(sv))
sv = SvRV(sv);
@@ -30,19 +28,15 @@
src = SvPVbyte(sv, src_len);
if (! src_len)
XSRETURN_NO;
- dest_len = csnappy_max_compressed_length(src_len);
+ dest_len = snappy_max_compressed_length(src_len);
if (! dest_len)
XSRETURN_UNDEF;
- Newx(working_memory, CSNAPPY_WORKMEM_BYTES, void *);
- if (! working_memory)
- XSRETURN_UNDEF;
RETVAL = newSV(dest_len);
dest = SvPVX(RETVAL);
if (! dest)
XSRETURN_UNDEF;
- csnappy_compress(src, src_len, dest, &dest_len, working_memory,
- CSNAPPY_WORKMEM_BYTES_POWER_OF_TWO);
- Safefree(working_memory);
+ if (snappy_compress(src, src_len, dest, &dest_len) != SNAPPY_OK)
+ XSRETURN_UNDEF;
SvCUR_set(RETVAL, dest_len);
SvPOK_on(RETVAL);
OUTPUT:
@@ -56,8 +50,7 @@
PREINIT:
char *src, *dest;
STRLEN src_len;
- uint32_t dest_len;
- int header_len;
+ size_t dest_len;
CODE:
PERL_UNUSED_VAR(ix); /* -W */
if (SvROK(sv))
@@ -67,15 +60,13 @@
src = SvPVbyte(sv, src_len);
if (! src_len)
XSRETURN_NO;
- header_len = csnappy_get_uncompressed_length(src, src_len, &dest_len);
- if (0 > header_len || ! dest_len)
+ if (snappy_uncompressed_length(src, src_len, &dest_len) != SNAPPY_OK)
XSRETURN_UNDEF;
RETVAL = newSV(dest_len);
dest = SvPVX(RETVAL);
if (! dest)
XSRETURN_UNDEF;
- if (csnappy_decompress_noheader(src + header_len, src_len - header_len,
- dest, &dest_len))
+ if (snappy_uncompress(src, src_len, dest, &dest_len) != SNAPPY_OK)
XSRETURN_UNDEF;
SvCUR_set(RETVAL, dest_len);
SvPOK_on(RETVAL);