diff options
author | Adam Mitz <mitza@ociweb.com> | 2015-11-06 17:07:11 -0600 |
---|---|---|
committer | Adam Mitz <mitza@ociweb.com> | 2015-11-06 17:07:11 -0600 |
commit | ac5e1702c9f9bee9f1f7bfce8c1a6f3847ea6b4b (patch) | |
tree | 0e70d1f51c39e688a05a6cdc2af58408222e4a0d /ACE/ace/Logging_Strategy.cpp | |
parent | 5272b5b81f92c298cb998b5bb0b0dbca3e7f29fe (diff) | |
download | ATCD-ac5e1702c9f9bee9f1f7bfce8c1a6f3847ea6b4b.tar.gz |
Merged branch ace-face-safety (FACE Safety Profile import from OCITAO).
Diffstat (limited to 'ACE/ace/Logging_Strategy.cpp')
-rw-r--r-- | ACE/ace/Logging_Strategy.cpp | 60 |
1 files changed, 45 insertions, 15 deletions
diff --git a/ACE/ace/Logging_Strategy.cpp b/ACE/ace/Logging_Strategy.cpp index 62891db3ab4..b520b0f1abb 100644 --- a/ACE/ace/Logging_Strategy.cpp +++ b/ACE/ace/Logging_Strategy.cpp @@ -173,7 +173,11 @@ ACE_Logging_Strategy::parse_args (int argc, ACE_TCHAR *argv[]) case 'k': // Ensure that the LOGGER flag is set ACE_SET_BITS (this->flags_, ACE_Log_Msg::LOGGER); +#if defined (ACE_HAS_ALLOC_HOOKS) + ACE_Allocator::instance()->free(this->logger_key_); +#else delete [] this->logger_key_; +#endif /* ACE_HAS_ALLOC_HOOKS */ this->logger_key_ = ACE::strnew (get_opt.opt_arg ()); break; case 'm': @@ -182,7 +186,11 @@ ACE_Logging_Strategy::parse_args (int argc, ACE_TCHAR *argv[]) this->max_size_ <<= 10; // convert from KB to bytes. break; case 'n': +#if defined (ACE_HAS_ALLOC_HOOKS) + ACE_Allocator::instance()->free(this->program_name_); +#else delete [] this->program_name_; +#endif /* ACE_HAS_ALLOC_HOOKS */ this->program_name_ = ACE::strnew (get_opt.opt_arg ()); break; case 'N': @@ -202,7 +210,11 @@ ACE_Logging_Strategy::parse_args (int argc, ACE_TCHAR *argv[]) case 's': // Ensure that the OSTREAM flag is set ACE_SET_BITS (this->flags_, ACE_Log_Msg::OSTREAM); +#if defined (ACE_HAS_ALLOC_HOOKS) + ACE_Allocator::instance()->free(this->filename_); +#else delete [] this->filename_; +#endif /* ACE_HAS_ALLOC_HOOKS */ this->filename_ = ACE::strnew (get_opt.opt_arg ()); break; case 't': @@ -241,8 +253,13 @@ ACE_Logging_Strategy::ACE_Logging_Strategy (void) #if defined (ACE_DEFAULT_LOGFILE) this->filename_ = ACE::strnew (ACE_DEFAULT_LOGFILE); #else /* ACE_DEFAULT_LOGFILE */ +#if defined (ACE_HAS_ALLOC_HOOKS) + ACE_ALLOCATOR (this->filename_, + static_cast<ACE_TCHAR *>(ACE_Allocator::instance()->malloc(sizeof(ACE_TCHAR) * (MAXPATHLEN + 1)))); +#else ACE_NEW (this->filename_, ACE_TCHAR[MAXPATHLEN + 1]); +#endif /* ACE_HAS_ALLOC_HOOKS */ // Get the temporary directory if (ACE::get_temp_dir @@ -265,17 +282,30 @@ ACE_Logging_Strategy::~ACE_Logging_Strategy (void) { // This is allocated in constructor, so it must be deallocated in // the destructor! +#if defined (ACE_HAS_ALLOC_HOOKS) + ACE_Allocator::instance()->free(this->filename_); +#else delete [] this->filename_; +#endif /* ACE_HAS_ALLOC_HOOKS */ } int ACE_Logging_Strategy::fini (void) { +#if defined (ACE_HAS_ALLOC_HOOKS) + ACE_Allocator::instance()->free(this->filename_); +#else delete [] this->filename_; +#endif /* ACE_HAS_ALLOC_HOOKS */ this->filename_ = 0; // Avoid double deletions. +#if defined (ACE_HAS_ALLOC_HOOKS) + ACE_Allocator::instance()->free(this->logger_key_); + ACE_Allocator::instance()->free(this->program_name_);; +#else delete [] this->logger_key_; delete [] this->program_name_; +#endif /* ACE_HAS_ALLOC_HOOKS */ if (this->reactor () && this->interval_ > 0 && this->max_size_ > 0) @@ -476,14 +506,14 @@ ACE_Logging_Strategy::handle_timeout (const ACE_Time_Value &, for (int i = max_num ; i > 1 ;i--) { - ACE_OS::sprintf (backup, - ACE_TEXT ("%s.%d"), - this->filename_, - i); - ACE_OS::sprintf (to_backup, - ACE_TEXT ("%s.%d"), - this->filename_, - i - 1); + ACE_OS::snprintf (backup, MAXPATHLEN + 1, + ACE_TEXT ("%s.%d"), + this->filename_, + i); + ACE_OS::snprintf (to_backup, MAXPATHLEN + 1, + ACE_TEXT ("%s.%d"), + this->filename_, + i - 1); // Remove any existing old file; ignore error as // file may not exist. @@ -493,19 +523,19 @@ ACE_Logging_Strategy::handle_timeout (const ACE_Time_Value &, // backup log file. ACE_OS::rename (to_backup, backup); } - ACE_OS::sprintf (backup, - ACE_TEXT ("%s.1"), - this->filename_); + ACE_OS::snprintf (backup, MAXPATHLEN + 1, + ACE_TEXT ("%s.1"), + this->filename_); } else { if (fixed_number_ && count_>max_file_number_) count_ = 1; // start over from 1 - ACE_OS::sprintf (backup, - ACE_TEXT ("%s.%d"), - this->filename_, - count_); + ACE_OS::snprintf (backup, MAXPATHLEN + 1, + ACE_TEXT ("%s.%d"), + this->filename_, + count_); } // Remove any existing old file; ignore error as file may |