diff options
Diffstat (limited to 'ace/Singleton.cpp')
-rw-r--r-- | ace/Singleton.cpp | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/ace/Singleton.cpp b/ace/Singleton.cpp index 5d6a6e8ea31..4a07aedb70c 100644 --- a/ace/Singleton.cpp +++ b/ace/Singleton.cpp @@ -44,7 +44,25 @@ ACE_Singleton<TYPE, LOCK>::instance (void) ACE_GUARD_RETURN (LOCK, ace_mon, ace_singleton_lock_, 0); if (instance_ == 0) - ACE_NEW_RETURN (instance_, TYPE, 0); + { + // We can replace the following lines with this line once we + // update the macro in OS.h + // ACE_NEW_RETURN (instance_, TYPE, 0); + + instance_ = new TYPE; + if (instance_ == 0) + { + errno = ENOMEM; + return 0; + } + else if (ACE_LOG_MSG->op_status () == -1) + { + errno = ACE_LOG_MSG->errnum (); + delete instance_; + instance_ = 0; + return 0; + } + } } return instance_; @@ -56,7 +74,25 @@ ACE_Singleton<TYPE, LOCK>::instance (void) ACE_GUARD_RETURN (LOCK, ace_mon, (ACE_Singleton<TYPE, LOCK>::ace_singleton_lock_), 0); if (ACE_Singleton<TYPE, LOCK>::instance_ == 0) - ACE_NEW_RETURN ((ACE_Singleton<TYPE, LOCK>::instance_), TYPE, 0); + { + // We can replace the following lines with this line once we + // update the macro in OS.h + // ACE_NEW_RETURN ((ACE_Singleton<TYPE, LOCK>::instance_), TYPE, 0); + + instance_ = new TYPE; + if (instance_ == 0) + { + errno = ENOMEM; + return 0; + } + else if (ACE_LOG_MSG->op_status () == -1) + { + errno = ACE_LOG_MSG->errnum (); + delete instance_; + instance_ = 0; + return 0; + } + } } return ACE_Singleton<TYPE, LOCK>::instance_; |