X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=plocate.cpp;h=62bc6e331d04a9e61bf76b479258109e50bda100;hb=db96666312961f730f7ea9e4a966fc43d73dbc1c;hp=eb00adac8cced544b8ef0db9524f85cfcd146722;hpb=9d1f32d695a463b1f158fc3c0e5a2dd94dcd6987;p=plocate diff --git a/plocate.cpp b/plocate.cpp index eb00ada..62bc6e3 100644 --- a/plocate.cpp +++ b/plocate.cpp @@ -316,8 +316,9 @@ void scan_file_block(const vector &needles, string_view compressed, string block; block.resize(uncompressed_len + 1); - size_t err = ZSTD_decompress(&block[0], block.size(), compressed.data(), - compressed.size()); + static ZSTD_DCtx *ctx = ZSTD_createDCtx(); // Reused across calls. + size_t err = ZSTD_decompressDCtx(ctx, &block[0], block.size(), compressed.data(), + compressed.size()); if (ZSTD_isError(err)) { fprintf(stderr, "ZSTD_decompress(): %s\n", ZSTD_getErrorName(err)); exit(1);