From c833f66d9fb14dd38db40249a2b722c3cee8f011 Mon Sep 17 00:00:00 2001 From: EntireTwix Date: Sat, 29 May 2021 20:11:02 -0700 Subject: [PATCH] :bug: seg fault bug fixed --- include/bank.hpp | 4 ++-- include/log.hpp | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/bank.hpp b/include/bank.hpp index 3df66da..dd2cd91 100644 --- a/include/bank.hpp +++ b/include/bank.hpp @@ -173,7 +173,7 @@ public: { if constexpr (max_log_size) { - Json::Value res; + Json::Value res; if (!users.if_contains(name, [&res, &attempt](const User &u) { if (u.password != XXH3_64bits(attempt.data(), attempt.size())) { @@ -187,7 +187,7 @@ public: { return -1; } - return res; + return res; } else { diff --git a/include/log.hpp b/include/log.hpp index 7861e61..5341036 100644 --- a/include/log.hpp +++ b/include/log.hpp @@ -10,9 +10,9 @@ struct Log uint32_t end = 0; void AddTrans(Transaction &&v) { - if (data.size() <= end+1 && end+1 < max_log_size) //if memory reserved is full + if (data.size() <= end + 1 && end + 1 < max_log_size) //if memory reserved is full { - if(data.size() + pre_log_size > max_log_size) + if (data.size() + pre_log_size > max_log_size) { data.resize(max_log_size); } @@ -26,7 +26,7 @@ struct Log data[i] = std::move(data[i - 1]); } data[0] = std::move(v); - end += (end < max_log_size); //branchless + end += (end + 1 < max_log_size); //branchless } Json::Value Serialize() const {