title: Thread safe pass-through operator
body: <p>I'm overriding <code>new()</code> and <code>new[]()</code> operators for our <em>heap memory manager</em>. <code>new()</code> has a <em>mutex</em> and is thread-safe, but I have not added a mutex to <code>new[]()</code>, which works as a <em>pass-through operator</em>, since I suspect it will be on the stack when called. Is it correct that <code>new[]()</code> will be on the stack and will not need a mutex of its own?</p>
  
  <pre><code>/*!
  \brief Override the Standard C++ new [] operator
  \param size [in] Number of bytes to allocate
  \exception std::bad_alloc
  \returns Pointer to the start of the allcoated memory block of \c size bytes
  \todo Check if this is thread-safe or if it needs a mutex lock, return address probably is on the stack so it should be ok
  */
  void *operator new[] (size_t size)
  {
      return operator new(size);
  }
  
  /*!
  \brief Overrides the Standard C++ new operator
  \param size [in] Number of bytes to allocate
  \exception std::bad_alloc
  \returns Pointer to the start of the allcoated memory block of \c size bytes
  */
  void *operator new(size_t size) 
  {
      MM_ENTER_CRITICAL_SECTION(CMemoryManager::mutex)
      // Memory manager code removed since it's outside of the question context
      MM_LEAVE_CRITICAL_SECTION(CMemoryManager::mutex)
  }
  </code></pre>