diff options
author | Jerome Jiang <jianj@google.com> | 2023-05-08 19:47:21 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2023-05-08 19:47:21 +0000 |
commit | 7ab013f8a9aad0dd14e3070349329209a243ee86 (patch) | |
tree | b4365087fb57e7a189fa55740ea1c32a5c3486a8 /vpx/internal/vpx_codec_internal.h | |
parent | 62cd0c9c3e23e31df8141d6dfaa31726d15bed99 (diff) | |
parent | 1710c9282a11aaaccdf42b7507f570f58e39b7fd (diff) | |
download | libvpx-7ab013f8a9aad0dd14e3070349329209a243ee86.tar.gz |
Merge "Unify implementation of CHECK_MEM_ERROR" into main
Diffstat (limited to 'vpx/internal/vpx_codec_internal.h')
-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) |