Tests: Fix memory leaks in test_block_header.
[xz/debian.git] / src / liblzma / simple / simple_encoder.c
blobd2cc03e58b81e9e453c9260dbdf8de5a957c370f
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 /// \file simple_encoder.c
4 /// \brief Properties encoder for simple filters
5 //
6 // Author: Lasse Collin
7 //
8 // This file has been put into the public domain.
9 // You can do whatever you want with this file.
11 ///////////////////////////////////////////////////////////////////////////////
13 #include "simple_encoder.h"
16 extern lzma_ret
17 lzma_simple_props_size(uint32_t *size, const void *options)
19 const lzma_options_bcj *const opt = options;
20 *size = (opt == NULL || opt->start_offset == 0) ? 0 : 4;
21 return LZMA_OK;
25 extern lzma_ret
26 lzma_simple_props_encode(const void *options, uint8_t *out)
28 const lzma_options_bcj *const opt = options;
30 // The default start offset is zero, so we don't need to store any
31 // options unless the start offset is non-zero.
32 if (opt == NULL || opt->start_offset == 0)
33 return LZMA_OK;
35 write32le(out, opt->start_offset);
37 return LZMA_OK;