diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2018-01-03 21:36:51 +0000 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2018-01-15 00:35:24 +0000 |
commit | 411da337d2026b8c4603484c4b8300ea933b10c0 (patch) | |
tree | f378d86bc178b06500b38f863fc1f961e1f2310e /src | |
parent | Merge pull request #3091 (diff) | |
download | monero-411da337d2026b8c4603484c4b8300ea933b10c0.tar.xz |
perf_timer: use std::unique_ptr instead of new/delete
Diffstat (limited to 'src')
-rw-r--r-- | src/common/perf_timer.h | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/common/perf_timer.h b/src/common/perf_timer.h index a1d71609c..2b318bff2 100644 --- a/src/common/perf_timer.h +++ b/src/common/perf_timer.h @@ -30,6 +30,7 @@ #include <string> #include <stdio.h> +#include <memory> #include "misc_log_ex.h" #undef MONERO_DEFAULT_LOG_CATEGORY @@ -62,8 +63,8 @@ void set_performance_timer_log_level(el::Level level); #define PERF_TIMER_UNIT_L(name, unit, l) tools::PerformanceTimer pt_##name(#name, unit, l) #define PERF_TIMER(name) PERF_TIMER_UNIT(name, 1000) #define PERF_TIMER_L(name, l) PERF_TIMER_UNIT_L(name, 1000, l) -#define PERF_TIMER_START_UNIT(name, unit) tools::PerformanceTimer *pt_##name = new tools::PerformanceTimer(#name, unit, el::Level::Info) +#define PERF_TIMER_START_UNIT(name, unit) std::unique_ptr<tools::PerformanceTimer> pt_##name(new tools::PerformanceTimer(#name, unit, el::Level::Info)) #define PERF_TIMER_START(name) PERF_TIMER_START_UNIT(name, 1000) -#define PERF_TIMER_STOP(name) do { delete pt_##name; pt_##name = NULL; } while(0) +#define PERF_TIMER_STOP(name) do { pt_##name.reset(NULL); } while(0) } |