compression.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /**
  2. * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
  3. * SPDX-License-Identifier: Apache-2.0.
  4. */
  5. #include <aws/compression/compression.h>
  6. #define DEFINE_ERROR_INFO(CODE, STR) \
  7. [(CODE)-AWS_ERROR_ENUM_BEGIN_RANGE(AWS_C_COMPRESSION_PACKAGE_ID)] = \
  8. AWS_DEFINE_ERROR_INFO(CODE, STR, "aws-c-compression")
  9. /* clang-format off */
  10. static struct aws_error_info s_errors[] = {
  11. DEFINE_ERROR_INFO(
  12. AWS_ERROR_COMPRESSION_UNKNOWN_SYMBOL,
  13. "Compression encountered an unknown symbol."),
  14. };
  15. /* clang-format on */
  16. static struct aws_error_info_list s_error_list = {
  17. .error_list = s_errors,
  18. .count = AWS_ARRAY_SIZE(s_errors),
  19. };
  20. static bool s_library_initialized = false;
  21. void aws_compression_library_init(struct aws_allocator *alloc) {
  22. if (s_library_initialized) {
  23. return;
  24. }
  25. s_library_initialized = true;
  26. aws_common_library_init(alloc);
  27. aws_register_error_info(&s_error_list);
  28. }
  29. void aws_compression_library_clean_up(void) {
  30. if (!s_library_initialized) {
  31. return;
  32. }
  33. s_library_initialized = false;
  34. aws_unregister_error_info(&s_error_list);
  35. aws_common_library_clean_up();
  36. }