diff --git a/src/backend/utils/mmgr/mcxt.c b/src/backend/utils/mmgr/mcxt.c
index 4939046..de011fe 100644
--- a/src/backend/utils/mmgr/mcxt.c
+++ b/src/backend/utils/mmgr/mcxt.c
@@ -23,6 +23,11 @@
 
 #include "utils/memutils.h"
 
+#undef MemoryContextAlloc
+#undef MemoryContextAllocZero
+#undef MemoryContextAllocZeroAligned
+#undef repalloc
+
 
 /*****************************************************************************
  *	  GLOBAL MEMORY															 *
diff --git a/src/include/utils/palloc.h b/src/include/utils/palloc.h
index e504ffa..d6ac006 100644
--- a/src/include/utils/palloc.h
+++ b/src/include/utils/palloc.h
@@ -49,6 +49,10 @@ extern void *MemoryContextAlloc(MemoryContext context, Size size);
 extern void *MemoryContextAllocZero(MemoryContext context, Size size);
 extern void *MemoryContextAllocZeroAligned(MemoryContext context, Size size);
 
+#define MemoryContextAlloc(c,s) (MemoryContextAlloc((c),(s))?:(exit(1),NULL))
+#define MemoryContextAllocZero(c,s) (MemoryContextAlloc((c),(s))?:(exit(1),NULL))
+#define MemoryContextAllocZeroAligned(c,s) (MemoryContextAlloc((c),(s))?:(exit(1),NULL))
+
 #define palloc(sz)	MemoryContextAlloc(CurrentMemoryContext, (sz))
 
 #define palloc0(sz) MemoryContextAllocZero(CurrentMemoryContext, (sz))
@@ -70,6 +74,8 @@ extern void pfree(void *pointer);
 
 extern void *repalloc(void *pointer, Size size);
 
+#define repalloc(p,s) (repalloc((p),(s))?:(exit(1),NULL))
+
 /*
  * MemoryContextSwitchTo can't be a macro in standard C compilers.
  * But we can make it an inline function when using GCC.
