1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
|
Description: link with libsnappy-dev instead of embedded source of csnappy
Forwarded: not-needed
Author: gregor herrmann <gregoa@debian.org>
Last-Update: 2019-02-20
--- a/Snappy.xs
+++ b/Snappy.xs
@@ -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:
SvGETMAGIC(sv);
if (SvROK(sv) && ! SvAMAGIC(sv)) {
@@ -33,19 +31,14 @@
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);
+ snappy_compress(src, src_len, dest, &dest_len);
SvCUR_set(RETVAL, dest_len);
SvPOK_on(RETVAL);
OUTPUT:
@@ -59,7 +52,7 @@
PREINIT:
char *src, *dest;
STRLEN src_len;
- uint32_t dest_len;
+ size_t dest_len;
int header_len;
CODE:
PERL_UNUSED_VAR(ix); /* -W */
@@ -73,14 +66,14 @@
src = SvPVbyte(sv, src_len);
if (! src_len)
XSRETURN_NO;
- header_len = csnappy_get_uncompressed_length(src, src_len, &dest_len);
+ header_len = snappy_uncompressed_length(src, src_len, &dest_len);
if (0 > header_len || ! dest_len)
XSRETURN_UNDEF;
RETVAL = newSV(dest_len);
dest = SvPVX(RETVAL);
if (! dest)
XSRETURN_UNDEF;
- if (csnappy_decompress_noheader(src + header_len, src_len - header_len,
+ if (snappy_uncompress(src + header_len, src_len - header_len,
dest, &dest_len))
XSRETURN_UNDEF;
SvCUR_set(RETVAL, dest_len);
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -4,10 +4,9 @@
use ExtUtils::MakeMaker 6.52;
use Devel::CheckLib;
-my $ctz = check_lib(
- lib => 'c',
- function => 'return (__builtin_ctzll(0x100000000LL) != 32);'
-) ? '-DHAVE_BUILTIN_CTZ' : '';
+my $snappy = check_lib(
+ lib => 'snappy'
+) ? '-lsnappy' : '';
my %conf = (
NAME => 'Compress::Snappy',
@@ -30,7 +29,7 @@
},
},
- DEFINE => $ctz,
+ LIBS => [ $snappy ],
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
clean => { FILES => 'Compress-Snappy-*' },
|