-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#575 use unique_ptr to make valgrind happy
- While there is no actual memory leak for a static lifetime object required for the duration of the program, failure to delete the object can result in tooling reporting false positives.. Anyway, also fixed the slight 'not quite in spec' usage of the MEMBER STATIC variables (which are not strictly qualified under constant initialization..), reduced the exposed definition, and improved comments.
- Loading branch information
Showing
2 changed files
with
28 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,32 @@ | ||
#include "vt/trace/trace_common.h" | ||
#include "vt/trace/trace_containers.h" | ||
|
||
#include <memory> | ||
|
||
namespace vt { namespace trace { | ||
|
||
// These MUST have static-lifetime and be initialized during constant | ||
// initialization as they are modified during dynamic initialization as | ||
// that is when auto-handler events are registered. | ||
// Using a constexpr constructor / initializer list is also relevant. | ||
// - https://en.cppreference.com/w/cpp/language/constant_initialization | ||
static std::unique_ptr<TraceContainerEventClassType> event_type_container_{}; | ||
static std::unique_ptr<TraceContainerEventType> event_container_{}; | ||
|
||
/*static*/ TraceContainerEventClassType* | ||
TraceContainers::event_type_container_; | ||
TraceContainers::getEventTypeContainer(){ | ||
if (event_type_container_ == nullptr) { | ||
event_type_container_ = std::make_unique<TraceContainerEventClassType>(); | ||
} | ||
return event_type_container_.get(); | ||
} | ||
|
||
/*static*/ TraceContainerEventType* | ||
TraceContainers::event_container_; | ||
TraceContainers::getEventContainer(){ | ||
if (event_container_ == nullptr) { | ||
event_container_ = std::make_unique<TraceContainerEventType>(); | ||
} | ||
return event_container_.get(); | ||
} | ||
|
||
}} //end namespace vt::trace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0e8f927
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lifflander Also, this does not fix some known SEGV's that can occur during event registration. The 'reduce' example is one of several that will not run with tracing on this build. (It is likely related to handlers wrapping
operator()
.)