*pnDest = (int)rc;
return SQLITE_OK;
}
-static int zfZstdUncompressSize(
- void *p,
- const u8 *aSrc, int nSrc
-){
+static int zfZstdUncompressSize(void *p, const u8 *aSrc, int nSrc){
return (int)ZSTD_getFrameContentSize(aSrc, (size_t)nSrc);
}
static int zfZstdUncompress(
*pnDest = (int)rc;
return SQLITE_OK;
}
-static int zfZstddictUncompressSize(
- void *p,
- const u8 *aSrc, int nSrc
-){
+static int zfZstddictUncompressSize(void *p, const u8 *aSrc, int nSrc){
return (int)ZSTD_getFrameContentSize(aSrc, (size_t)nSrc);
}
static int zfZstddictUncompress(
}
#endif
+#ifdef SQLITE_HAVE_LZ4
+#include <lz4.h>
+#include <lz4hc.h>
+static int zfLz4Open(void **pp, u8 *aDict, int nDict){
+ *pp = 0;
+ return SQLITE_OK;
+}
+static void zfLz4Close(void *p){
+}
+static int zfLz4CompressBound(void *p, int nSrc){
+ return (int)LZ4_compressBound((uLong)nSrc) + 4;
+}
+static int zfLz4Uncompress(
+ void *p,
+ u8 *aDest, int nDest,
+ const u8 *aSrc, int nSrc
+){
+ int rc = LZ4_decompress_safe(
+ (const char*)&aSrc[4], (char*)aDest, nSrc-4, nDest
+ );
+ return rc==nDest ? SQLITE_OK : SQLITE_ERROR;
+}
+static int zfLz4Compress(
+ void *p,
+ u8 *aDest, int *pnDest,
+ const u8 *aSrc, int nSrc
+){
+ int rc = LZ4_compress_default(
+ (const char*)aSrc, (char*)&aDest[4], nSrc, (*pnDest - 4)
+ );
+ *pnDest = rc+4;
+ zonefilePut32(aDest, nSrc);
+ return rc==0 ? SQLITE_ERROR : SQLITE_OK;
+}
+static int zfLz4UncompressSize(void *p, const u8 *aSrc, int nSrc){
+ return (int)zonefileGet32(aSrc);
+}
+static int zfLz4hcCompress(
+ void *p,
+ u8 *aDest, int *pnDest,
+ const u8 *aSrc, int nSrc
+){
+ int rc = LZ4_compress_HC(
+ (const char*)aSrc, (char*)&aDest[4], nSrc, *pnDest, 0
+ );
+ *pnDest = rc+4;
+ zonefilePut32(aDest, nSrc);
+ return rc==0 ? SQLITE_ERROR : SQLITE_OK;
+}
+#endif
+
typedef struct ZonefileCompress ZonefileCompress;
static struct ZonefileCompress {
int eType;
#endif /* SQLITE_HAVE_BROTLI */
#ifdef SQLITE_HAVE_LZ4
{ ZONEFILE_COMPRESSION_LZ4, "lz4",
- 0, 0, 0, 0, 0, 0, 0
+ zfLz4Open, zfLz4Close,
+ 0,
+ zfLz4CompressBound, zfLz4Compress,
+ zfLz4UncompressSize, zfLz4Uncompress
},
{ ZONEFILE_COMPRESSION_LZ4HC, "lz4hc",
- 0, 0, 0, 0, 0, 0, 0
+ zfLz4Open, zfLz4Close,
+ 0,
+ zfLz4CompressBound, zfLz4hcCompress,
+ zfLz4UncompressSize, zfLz4Uncompress
},
#endif /* SQLITE_HAVE_LZ4 */
};
ZonefileBuffer *pFrom /* Input buffer */
){
int rc = SQLITE_OK;
- if( pMethod->eType==ZONEFILE_COMPRESSION_NONE ){
- if( zonefileBufferGrow(pCtx, pTo, pFrom->n) ){
- rc = SQLITE_ERROR;
+ if( pFrom->n ){
+ if( pMethod->eType==ZONEFILE_COMPRESSION_NONE ){
+ if( zonefileBufferGrow(pCtx, pTo, pFrom->n) ){
+ rc = SQLITE_ERROR;
+ }else{
+ zonefileAppendBlob(pTo, pFrom->a, pFrom->n);
+ }
}else{
- zonefileAppendBlob(pTo, pFrom->a, pFrom->n);
- }
- }else{
- int nReq = pMethod->xCompressBound(pCmp, pFrom->n);
- if( zonefileBufferGrow(pCtx, pTo, nReq) ) return SQLITE_ERROR;
- rc = pMethod->xCompress(pCmp, &pTo->a[pTo->n], &nReq, pFrom->a, pFrom->n);
- pTo->n += nReq;
- if( rc!=SQLITE_OK ){
- return rc;
+ int nReq = pMethod->xCompressBound(pCmp, pFrom->n);
+ if( zonefileBufferGrow(pCtx, pTo, nReq) ) return SQLITE_ERROR;
+ rc = pMethod->xCompress(pCmp, &pTo->a[pTo->n], &nReq, pFrom->a, pFrom->n);
+ pTo->n += nReq;
+ if( rc!=SQLITE_OK ){
+ return rc;
+ }
}
}
return SQLITE_OK;
*paIdx = aIdx;
*pnIdx = nIdx;
- return SQLITE_OK;
+ return rc;
}
-C Add\ssupport\sfor\scompression\smethods\s"zstd"\sand\s"zstd_global_dict".
-D 2018-02-17T18:33:43.145
+C Add\ssupport\sfor\scompression\stypes\s"lz4"\sand\s"lz4hc"\sto\sthe\szonefile\smodule.
+D 2018-02-17T19:38:02.757
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F Makefile.in 7a3f714b4fcf793108042b7b0a5c720b0b310ec84314d61ba7f3f49f27e550ea
F ext/userauth/user-auth.txt e6641021a9210364665fe625d067617d03f27b04
F ext/userauth/userauth.c 3410be31283abba70255d71fd24734e017a4497f
F ext/zonefile/README.md 387ad2b748e98eeea21fd4dbb609fefe313263fadb3fc6c01c512b4c95e55ae4
-F ext/zonefile/zonefile.c 3954cdaeae3ce5018be5e75022cbd5d142245828a8396ae35db64c2b379f3205
+F ext/zonefile/zonefile.c cb0e2d294bc064bd995e9df7737636395e3101b17de688b2cf0e2159e561482c
F ext/zonefile/zonefile1.test 0f84e56cd4f7b2c05443d1a2632c20ef635cc7f92de2868d92a2a6c09a9258ad
F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x
F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 72b8a7ef98d84460718378b9d17477599df39b4216015f8967674dd02b54b406
-R 3137d370c8b0ed559bfb7417aaf06af5
+P a993a50bb8d5a3bf7cf79e09204814e172ba0bf9b3949e81912ef83f0d4bb44e
+R 446a2537d684855afb526eb1141b7e7d
U dan
-Z cfd4dcc32b639975b3448fc063f18d5e
+Z 61481f5925196a4938887596830579d3