Actually manage memory in the old-style AOS logging
LeakSanitizer should be happy with it now. It's also still just as
thread-safe.
Change-Id: Id09a0349657cf4f719267b053f0ea3d8ec366256
diff --git a/aos/logging/context.cc b/aos/logging/context.cc
index 84e4e80..2c689ed 100644
--- a/aos/logging/context.cc
+++ b/aos/logging/context.cc
@@ -21,6 +21,7 @@
#include "aos/complex_thread_local.h"
#include "aos/die.h"
+#include "aos/logging/implementations.h"
namespace aos {
namespace logging {
@@ -71,10 +72,7 @@
} // namespace
-::std::atomic<LogImplementation *> global_top_implementation(NULL);
-
-Context::Context()
- : implementation(global_top_implementation.load()), sequence(0) {
+Context::Context() : implementation(GetImplementation()), sequence(0) {
cork_data.Reset();
}
@@ -105,6 +103,11 @@
void Context::Delete() { delete_current_context = true; }
+void Context::DeleteNow() {
+ my_context.Clear();
+ delete_current_context = false;
+}
+
} // namespace internal
} // namespace logging
} // namespace aos