From a3bf0509e01c6b32a13cfd16060e4a537706f231 Mon Sep 17 00:00:00 2001 From: David Chen Date: Wed, 1 Nov 2017 16:57:43 -0700 Subject: [PATCH] Fixes LogEvent constructor to use reference. Previously when fixing LogEvent missing strings because of pointer lifetime issues, I had the constructor for LogEvent pass log_msg by value. This fixes log_msg to pass by reference again so that we avoid wasting memory. Test: Checked statsd unit-tests still pass. Change-Id: I94ac4d1bed19fec19d44e27fe94e07ab30383363 --- cmds/statsd/src/logd/LogEvent.cpp | 2 +- cmds/statsd/src/logd/LogEvent.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cmds/statsd/src/logd/LogEvent.cpp b/cmds/statsd/src/logd/LogEvent.cpp index 1a039f6d61c56..b23446c08b055 100644 --- a/cmds/statsd/src/logd/LogEvent.cpp +++ b/cmds/statsd/src/logd/LogEvent.cpp @@ -29,7 +29,7 @@ using android::util::ProtoOutputStream; // We need to keep a copy of the android_log_event_list owned by this instance so that the char* // for strings is not cleared before we can read them. -LogEvent::LogEvent(log_msg msg) : mList(msg) { +LogEvent::LogEvent(log_msg& msg) : mList(msg) { init(msg.entry_v1.sec * NS_PER_SEC + msg.entry_v1.nsec, &mList); } diff --git a/cmds/statsd/src/logd/LogEvent.h b/cmds/statsd/src/logd/LogEvent.h index 9ef20ea6968c5..df75d9f2e0b15 100644 --- a/cmds/statsd/src/logd/LogEvent.h +++ b/cmds/statsd/src/logd/LogEvent.h @@ -42,7 +42,7 @@ public: /** * Read a LogEvent from a log_msg. */ - explicit LogEvent(log_msg msg); + explicit LogEvent(log_msg& msg); /** * Constructs a LogEvent with the specified tag and creates an android_log_event_list in write