From e28f30bcecf136d04ea8fe3035d0d308309dc42a Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Thu, 9 Nov 2023 15:28:17 -0500 Subject: [PATCH] fix uninit error --- include/blt/profiling/profiler_v2.h | 8 +++++++- include/blt/std/memory.h | 4 ++-- src/blt/profiling/profiler_v2.cpp | 8 ++++++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/include/blt/profiling/profiler_v2.h b/include/blt/profiling/profiler_v2.h index 3ad1486..bfebbd1 100644 --- a/include/blt/profiling/profiler_v2.h +++ b/include/blt/profiling/profiler_v2.h @@ -51,6 +51,11 @@ namespace blt std::uint64_t count = 0; std::string interval_name; + + interval_t() = default; + + interval_t(pf_time_t wallStart, pf_time_t wallEnd, pf_time_t wallTotal, pf_time_t threadStart, pf_time_t threadEnd, pf_time_t threadTotal, + pf_cycle_t cyclesStart, pf_cycle_t cyclesEnd, pf_cycle_t cyclesTotal, uint64_t count, std::string intervalName); }; struct cycle_interval_t @@ -82,7 +87,8 @@ namespace blt void startInterval(interval_t* interval); - inline interval_t* startInterval(profile_t& profiler, std::string interval_name){ + inline interval_t* startInterval(profile_t& profiler, std::string interval_name) + { auto* p = createInterval(profiler, std::move(interval_name)); startInterval(p); return p; diff --git a/include/blt/std/memory.h b/include/blt/std/memory.h index 5eec990..7c4cfba 100755 --- a/include/blt/std/memory.h +++ b/include/blt/std/memory.h @@ -198,7 +198,7 @@ namespace blt if constexpr (std::is_trivially_copyable_v) { - std::memcpy(_buffer, copy._buffer, copy.size()); + std::memcpy(_buffer, copy._buffer, copy.size() * sizeof(T)); } else { if constexpr (std::is_copy_constructible_v && !std::is_copy_assignable_v) @@ -228,7 +228,7 @@ namespace blt if constexpr (std::is_trivially_copyable_v) { - std::memcpy(_buffer, copy._buffer, copy.size()); + std::memcpy(_buffer, copy._buffer, copy.size() * sizeof(T)); } else { if constexpr (std::is_copy_constructible_v && !std::is_copy_assignable_v) diff --git a/src/blt/profiling/profiler_v2.cpp b/src/blt/profiling/profiler_v2.cpp index 08c893d..87aec10 100644 --- a/src/blt/profiling/profiler_v2.cpp +++ b/src/blt/profiling/profiler_v2.cpp @@ -248,4 +248,12 @@ namespace blt blt::printProfile(profile, flags, sort, log_level); profiles.erase(profile_name); } + + interval_t::interval_t(pf_time_t wallStart, pf_time_t wallEnd, pf_time_t wallTotal, pf_time_t threadStart, pf_time_t threadEnd, + pf_time_t threadTotal, pf_cycle_t cyclesStart, pf_cycle_t cyclesEnd, pf_cycle_t cyclesTotal, uint64_t count, + std::string intervalName): + wall_start(wallStart), wall_end(wallEnd), wall_total(wallTotal), thread_start(threadStart), thread_end(threadEnd), + thread_total(threadTotal), cycles_start(cyclesStart), cycles_end(cyclesEnd), cycles_total(cyclesTotal), count(count), + interval_name(std::move(intervalName)) + {} } \ No newline at end of file