[mpich2-commits] r7781 - mpich2/trunk/src/include
goodell at mcs.anl.gov
goodell at mcs.anl.gov
Thu Jan 20 16:08:46 CST 2011
Author: goodell
Date: 2011-01-20 16:08:46 -0600 (Thu, 20 Jan 2011)
New Revision: 7781
Modified:
mpich2/trunk/src/include/mpimem.h
Log:
add MPIU_CHKPMEM_CALLOC functionality
Same as the MALLOC variant, but it zeroes the memory first instead.
Reviewed by balaji at .
Modified: mpich2/trunk/src/include/mpimem.h
===================================================================
--- mpich2/trunk/src/include/mpimem.h 2011-01-20 22:08:44 UTC (rev 7780)
+++ mpich2/trunk/src/include/mpimem.h 2011-01-20 22:08:46 UTC (rev 7781)
@@ -384,6 +384,24 @@
#define MPIU_CHKPMEM_MALLOC_ORJUMP(pointer_,type_,nbytes_,rc_,name_) \
MPIU_CHKPMEM_MALLOC_ORSTMT(pointer_,type_,nbytes_,rc_,name_,goto fn_fail)
+/* now the CALLOC version for zeroed memory */
+#define MPIU_CHKPMEM_CALLOC(pointer_,type_,nbytes_,rc_,name_) \
+ MPIU_CHKPMEM_CALLOC_ORJUMP(pointer_,type_,nbytes_,rc_,name_)
+#define MPIU_CHKPMEM_CALLOC_ORJUMP(pointer_,type_,nbytes_,rc_,name_) \
+ MPIU_CHKPMEM_CALLOC_ORSTMT(pointer_,type_,nbytes_,rc_,name_,goto fn_fail)
+#define MPIU_CHKPMEM_CALLOC_ORSTMT(pointer_,type_,nbytes_,rc_,name_,stmt_) \
+ do { \
+ pointer_ = (type_)MPIU_Calloc(1, (nbytes_)); \
+ if (pointer_) { \
+ MPIU_Assert(mpiu_chkpmem_stk_sp_<mpiu_chkpmem_stk_sz_); \
+ mpiu_chkpmem_stk_[mpiu_chkpmem_stk_sp_++] = pointer_; \
+ } \
+ else if (nbytes_ > 0) { \
+ MPIU_CHKMEM_SETERR(rc_,nbytes_,name_); \
+ stmt_; \
+ } \
+ } while (0)
+
/* A special version for routines that only allocate one item */
#define MPIU_CHKPMEM_MALLOC1(pointer_,type_,nbytes_,rc_,name_,stmt_) \
{pointer_ = (type_)MPIU_Malloc(nbytes_); \
More information about the mpich2-commits
mailing list