]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
minor: use MEM_writeLE24()
authorYann Collet <cyan@fb.com>
Fri, 20 Dec 2024 00:11:46 +0000 (16:11 -0800)
committerYann Collet <cyan@fb.com>
Fri, 20 Dec 2024 18:37:01 +0000 (10:37 -0800)
so that an empty frame needs only 3 bytes of dstCapacity.

lib/compress/zstd_compress.c

index b5e88325d60c9e9458d916ee194694b73f464c85..fcd8035fa47590cd5139116f94ad9b3bb6cf421c 100644 (file)
@@ -7213,8 +7213,8 @@ ZSTD_compressSequencesAndLiterals_internal(ZSTD_CCtx* cctx,
     /* Special case: empty frame */
     if ((nbSequences == 1) && (inSeqs[0].litLength == 0)) {
         U32 const cBlockHeader24 = 1 /* last block */ + (((U32)bt_raw)<<1);
-        RETURN_ERROR_IF(dstCapacity<4, dstSize_tooSmall, "No room for empty frame block header");
-        MEM_writeLE32(op, cBlockHeader24);
+        RETURN_ERROR_IF(dstCapacity<3, dstSize_tooSmall, "No room for empty frame block header");
+        MEM_writeLE24(op, cBlockHeader24);
         op += ZSTD_blockHeaderSize;
         dstCapacity -= ZSTD_blockHeaderSize;
         cSize += ZSTD_blockHeaderSize;