MCPcopy Create free account
hub / github.com/F-Stack/f-stack / rdbSaveLzfStringObject

Function rdbSaveLzfStringObject

app/redis-6.2.6/src/rdb.c:360–376  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

358}
359
360ssize_t rdbSaveLzfStringObject(rio *rdb, unsigned char *s, size_t len) {
361 size_t comprlen, outlen;
362 void *out;
363
364 /* We require at least four bytes compression for this to be worth it */
365 if (len <= 4) return 0;
366 outlen = len-4;
367 if ((out = zmalloc(outlen+1)) == NULL) return 0;
368 comprlen = lzf_compress(s, len, out, outlen);
369 if (comprlen == 0) {
370 zfree(out);
371 return 0;
372 }
373 ssize_t nwritten = rdbSaveLzfBlob(rdb, out, comprlen, len);
374 zfree(out);
375 return nwritten;
376}
377
378/* Load an LZF compressed string in RDB format. The returned value
379 * changes according to 'flags'. For more info check the

Callers 1

rdbSaveRawStringFunction · 0.85

Calls 4

zmallocFunction · 0.85
lzf_compressFunction · 0.85
rdbSaveLzfBlobFunction · 0.85
zfreeFunction · 0.70

Tested by

no test coverage detected