[x265] [PATCH] CHECKED_MALLOC: MALLOC returned pointer validation Macro

Gopu Govindaswamy gopu at multicorewareinc.com
Fri Sep 20 07:59:14 CEST 2013


# HG changeset patch
# User Gopu Govindaswamy <gopu at multicorewareinc.com>
# Date 1379656736 -19800
# Node ID 99a33fc4356a7daf3b09cd5e99687fa00e23051d
# Parent  20d8fa0541d8cf77d52106c08022ae97f3ff5de8
CHECKED_MALLOC: MALLOC returned pointer validation Macro

diff -r 20d8fa0541d8 -r 99a33fc4356a source/common/common.h
--- a/source/common/common.h	Thu Sep 19 22:26:46 2013 -0500
+++ b/source/common/common.h	Fri Sep 20 11:28:56 2013 +0530
@@ -96,6 +96,13 @@
 #define X265_MAX4(a, b, c, d) X265_MAX((a), X265_MAX3((b), (c), (d)))
 #define QP_BD_OFFSET (6*(X265_DEPTH-8))
 
+#define CHECKED_MALLOC(var, type, count )\
+{\
+    var = (type *)X265_MALLOC(type, sizeof(type) * (count));\
+    if( !var )\
+        goto fail;\
+}
+
 #define ENABLE_CYCLE_COUNTERS 0
 #if ENABLE_CYCLE_COUNTERS
 #include <intrin.h>


More information about the x265-devel mailing list