diff options
author | Jerome Jiang <jianj@google.com> | 2023-05-04 22:03:27 -0400 |
---|---|---|
committer | Jerome Jiang <jianj@google.com> | 2023-05-08 13:27:24 -0400 |
commit | 1710c9282a11aaaccdf42b7507f570f58e39b7fd (patch) | |
tree | b5b5bb9444950aacfa9270aace0eca3ba4c40e86 /vpx | |
parent | 75f9551efbef322b85534e91dd0b26c0c3bf18f4 (diff) | |
download | libvpx-1710c9282a11aaaccdf42b7507f570f58e39b7fd.tar.gz |
Unify implementation of CHECK_MEM_ERROR
There were multiple implementations of CHECK_MEM_ERROR across the
library that take different arguments and used in different places.
This CL will unify them and have only one implementation that takes
vpx_internal_error_info.
Change-Id: I2c568639473815bc00b1fc2b72be56e5ccba1a35
Diffstat (limited to 'vpx')
-rw-r--r-- | vpx/internal/vpx_codec_internal.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/vpx/internal/vpx_codec_internal.h b/vpx/internal/vpx_codec_internal.h index 670fe380e..aae321873 100644 --- a/vpx/internal/vpx_codec_internal.h +++ b/vpx/internal/vpx_codec_internal.h @@ -48,6 +48,8 @@ #include "../vpx_encoder.h" #include <stdarg.h> +#include "vpx_config.h" + #ifdef __cplusplus extern "C" { #endif @@ -427,6 +429,27 @@ struct vpx_internal_error_info { jmp_buf jmp; }; +#if CONFIG_DEBUG +#define CHECK_MEM_ERROR(error, lval, expr) \ + do { \ + assert((error)->setjmp); \ + (lval) = (expr); \ + if (!(lval)) \ + vpx_internal_error(error, VPX_CODEC_MEM_ERROR, \ + "Failed to allocate " #lval " at %s:%d", __FILE__, \ + __LINE__); \ + } while (0) +#else +#define CHECK_MEM_ERROR(error, lval, expr) \ + do { \ + assert((error)->setjmp); \ + (lval) = (expr); \ + if (!(lval)) \ + vpx_internal_error(error, VPX_CODEC_MEM_ERROR, \ + "Failed to allocate " #lval); \ + } while (0) +#endif + #define CLANG_ANALYZER_NORETURN #if defined(__has_feature) #if __has_feature(attribute_analyzer_noreturn) |