summaryrefslogtreecommitdiff
path: root/vpx/internal/vpx_codec_internal.h
diff options
context:
space:
mode:
authorJerome Jiang <jianj@google.com>2023-05-08 19:47:21 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2023-05-08 19:47:21 +0000
commit7ab013f8a9aad0dd14e3070349329209a243ee86 (patch)
treeb4365087fb57e7a189fa55740ea1c32a5c3486a8 /vpx/internal/vpx_codec_internal.h
parent62cd0c9c3e23e31df8141d6dfaa31726d15bed99 (diff)
parent1710c9282a11aaaccdf42b7507f570f58e39b7fd (diff)
downloadlibvpx-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.h23
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)