summaryrefslogtreecommitdiff
path: root/ACE/ace/OS_Memory.h
diff options
context:
space:
mode:
authorSteve Huston <shuston@riverace.com>2006-11-22 22:02:38 +0000
committerSteve Huston <shuston@riverace.com>2006-11-22 22:02:38 +0000
commit011181470ce99a9c6522f4ae343e3ffee7503186 (patch)
tree727adde8442af1a0c0c270a537e026fc0caffdd9 /ACE/ace/OS_Memory.h
parenteaecbaca808c1f046c7d87e66564cffc3809f133 (diff)
downloadATCD-011181470ce99a9c6522f4ae343e3ffee7503186.tar.gz
ChangeLogTag:Wed Nov 22 21:58:16 UTC 2006 Steve Huston <shuston@riverace.com>
Diffstat (limited to 'ACE/ace/OS_Memory.h')
-rw-r--r--ACE/ace/OS_Memory.h33
1 files changed, 18 insertions, 15 deletions
diff --git a/ACE/ace/OS_Memory.h b/ACE/ace/OS_Memory.h
index 2ca472e762e..70716bedfc2 100644
--- a/ACE/ace/OS_Memory.h
+++ b/ACE/ace/OS_Memory.h
@@ -81,6 +81,19 @@ ACE_END_VERSIONED_NAMESPACE_DECL
# endif
#endif
+// The Windows MFC exception mechanism requires that a caught CException
+// (including the CMemoryException in use here) be freed using its Delete()
+// method. Thus, when MFC is in use and we're catching exceptions as a result
+// of new(), the exception's Delete() method has to be called. No other
+// platform imposes this sort of restriction/requirement. The Windows
+// config stuff (at least for MSVC/MFC) defines a ACE_del_bad_alloc macro
+// that works with its ACE_bad_alloc macro to implement this cleanup
+// requirement. Since no other platform requires this, define it as
+// empty here.
+#if !defined (ACE_del_bad_alloc)
+# define ACE_del_bad_alloc
+#endif
+
#if defined (ACE_NEW_THROWS_EXCEPTIONS)
// Since new() throws exceptions, we need a way to avoid passing
@@ -145,12 +158,7 @@ ACE_END_VERSIONED_NAMESPACE_DECL
# elif defined (ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB)
# include /**/ <new>
# if !defined (ACE_bad_alloc)
- // MFC changes the behavior of operator new at all MSVC versions from 6 up.
-# if defined (ACE_HAS_MFC) && (ACE_HAS_MFC == 1)
-# define ACE_bad_alloc CMemoryException*
-# else
-# define ACE_bad_alloc std::bad_alloc
-# endif
+# define ACE_bad_alloc std::bad_alloc
# endif
# define ACE_nothrow std::nothrow
# define ACE_nothrow_t std::nothrow_t
@@ -163,12 +171,7 @@ ACE_END_VERSIONED_NAMESPACE_DECL
# else
# include /**/ <new>
# if !defined (ACE_bad_alloc)
- // MFC changes the behavior of operator new at all MSVC versions from 6 up.
-# if defined (ACE_HAS_MFC) && (ACE_HAS_MFC == 1)
-# define ACE_bad_alloc CMemoryException*
-# else
-# define ACE_bad_alloc bad_alloc
-# endif
+# define ACE_bad_alloc bad_alloc
# endif
# define ACE_nothrow nothrow
# define ACE_nothrow_t nothrow_t
@@ -198,17 +201,17 @@ ACE_END_VERSIONED_NAMESPACE_DECL
# define ACE_NEW_RETURN(POINTER,CONSTRUCTOR,RET_VAL) \
do { try { POINTER = new CONSTRUCTOR; } \
- catch (ACE_bad_alloc) { errno = ENOMEM; POINTER = 0; return RET_VAL; } \
+ catch (ACE_bad_alloc) { ACE_del_bad_alloc errno = ENOMEM; POINTER = 0; return RET_VAL; } \
} while (0)
# define ACE_NEW(POINTER,CONSTRUCTOR) \
do { try { POINTER = new CONSTRUCTOR; } \
- catch (ACE_bad_alloc) { errno = ENOMEM; POINTER = 0; return; } \
+ catch (ACE_bad_alloc) { ACE_del_bad_alloc errno = ENOMEM; POINTER = 0; return; } \
} while (0)
# define ACE_NEW_NORETURN(POINTER,CONSTRUCTOR) \
do { try { POINTER = new CONSTRUCTOR; } \
- catch (ACE_bad_alloc) { errno = ENOMEM; POINTER = 0; } \
+ catch (ACE_bad_alloc) { ACE_del_bad_alloc errno = ENOMEM; POINTER = 0; } \
} while (0)
# endif /* ACE_HAS_NEW_NOTHROW */