[mpich2-commits] r5484 - mpich2/trunk/src/include

gropp at mcs.anl.gov gropp at mcs.anl.gov
Mon Oct 19 03:05:04 CDT 2009


Author: gropp
Date: 2009-10-19 03:05:04 -0500 (Mon, 19 Oct 2009)
New Revision: 5484

Modified:
   mpich2/trunk/src/include/mpimem.h
Log:
Added check for nbytes_ > 0 to the memory macros to allow the use of 0 length memory requests; these macros will then signal an error only if both the pointer returned by malloc is null and the length is greater than zero

Modified: mpich2/trunk/src/include/mpimem.h
===================================================================
--- mpich2/trunk/src/include/mpimem.h	2009-10-18 19:21:07 UTC (rev 5483)
+++ mpich2/trunk/src/include/mpimem.h	2009-10-19 08:05:04 UTC (rev 5484)
@@ -311,7 +311,7 @@
 #define MPIU_CHKLMEM_FREEALL()
 #define MPIU_CHKLMEM_MALLOC_ORSTMT(pointer_,type_,nbytes_,rc_,name_,stmt_) \
 {pointer_ = (type_)alloca(nbytes_); \
-if (!(pointer_)) { \
+    if (!(pointer_) && (nbytes > 0)) {	   \
     MPIU_CHKMEM_SETERR(rc_,nbytes_,name_); \
     stmt_;\
 }}
@@ -326,7 +326,7 @@
 if (pointer_) { \
     MPIU_Assert(mpiu_chklmem_stk_sp_<mpiu_chklmem_stk_sz_);\
     mpiu_chklmem_stk_[mpiu_chklmem_stk_sp_++] = pointer_;\
-} else {\
+ } else if (nbytes_ > 0) {				 \
     MPIU_CHKMEM_SETERR(rc_,nbytes_,name_); \
     stmt_;\
 }}
@@ -353,7 +353,7 @@
 if (pointer_) { \
     MPIU_Assert(mpiu_chklbigmem_stk_sp_<mpiu_chklbigmem_stk_sz_);\
     mpiu_chklbigmem_stk_[mpiu_chklbigmem_stk_sp_++] = pointer_;\
-} else {\
+ } else if (nbytes_ > 0) {				       \
     MPIU_CHKMEM_SETERR(rc_,nbytes_,name_); \
     stmt_;\
 }}
@@ -376,7 +376,7 @@
 if (pointer_) { \
     MPIU_Assert(mpiu_chkpmem_stk_sp_<mpiu_chkpmem_stk_sz_);\
     mpiu_chkpmem_stk_[mpiu_chkpmem_stk_sp_++] = pointer_;\
-} else {\
+ } else if (nbytes_ > 0) {				 \
     MPIU_CHKMEM_SETERR(rc_,nbytes_,name_); \
     stmt_;\
 }}
@@ -396,7 +396,7 @@
 /* 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_); \
-if (!(pointer_)) { \
+    if (!(pointer_) && (nbytes_ > 0)) {	   \
     MPIU_CHKMEM_SETERR(rc_,nbytes_,name_); \
     stmt_;\
 }}



More information about the mpich2-commits mailing list