simple_decoder.c 992 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. /// \file simple_decoder.c
  4. /// \brief Properties decoder 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.
  10. //
  11. ///////////////////////////////////////////////////////////////////////////////
  12. #include "simple_decoder.h"
  13. extern lzma_ret
  14. lzma_simple_props_decode(void **options, const lzma_allocator *allocator,
  15. const uint8_t *props, size_t props_size)
  16. {
  17. if (props_size == 0)
  18. return LZMA_OK;
  19. if (props_size != 4)
  20. return LZMA_OPTIONS_ERROR;
  21. lzma_options_bcj *opt = lzma_alloc(
  22. sizeof(lzma_options_bcj), allocator);
  23. if (opt == NULL)
  24. return LZMA_MEM_ERROR;
  25. opt->start_offset = unaligned_read32le(props);
  26. // Don't leave an options structure allocated if start_offset is zero.
  27. if (opt->start_offset == 0)
  28. lzma_free(opt, allocator);
  29. else
  30. *options = opt;
  31. return LZMA_OK;
  32. }