From 96d3c1de080277339d6f89c6b061c0c9c8dd8292 Mon Sep 17 00:00:00 2001 From: EntireTwix Date: Thu, 29 Jul 2021 20:53:53 -0700 Subject: [PATCH] :bug: real max log size is 59 not 60 --- main.cpp | 2 +- src/log.cpp | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/main.cpp b/main.cpp index 9905af1..1301471 100644 --- a/main.cpp +++ b/main.cpp @@ -75,7 +75,7 @@ int main(int argc, char **argv) size_t num_of_logs = Bank::NumOfLogs(); size_t num_of_users = Bank::NumOfUsers(); std::cout << "\n\nLoaded " << num_of_users << " Users ~" << (float)(sizeof(User) * num_of_users) / 1048576 << "Mb" - << "\nLoaded " << num_of_logs << " Logs ~" << (float)(num_of_logs * (90 + 80 + (max_name_size * 2))) / 1048576 << "Mb" //90:string representation(heap), sizeof(Transaction), max_name_size*2:filled to&from(heap) + << "\nLoaded " << num_of_logs << " Logs ~" << (float)(num_of_logs * (91 + 80 + (max_name_size * 2))) / 1048576 << "Mb" //91:string representation(heap), sizeof(Transaction), max_name_size*2:filled to&from(heap) << "\nLoaded " << Bank::SumBal() << " CSH" << std::endl; //flushing before EventLoop diff --git a/src/log.cpp b/src/log.cpp index b146e95..e664c7b 100644 --- a/src/log.cpp +++ b/src/log.cpp @@ -15,8 +15,7 @@ std::string Log::GetLogs() noexcept if (log_flag.GetChangeState() && data.size()) //if there are changes { //re-generate snapshot - //({\"amount\":1,\"from\":\"\",\"time\":1625943626,\"to\":\"\"}, + (2*max_name_size)+10+10) * # of logs) + 1 - size_t predicted_size = ((60 + (2 * max_name_size)) * data.size()) + 1; + size_t predicted_size = ((59 + (2 * max_name_size)) * data.size()) + 1; if (log_snapshot.capacity() < predicted_size) { log_snapshot.reserve(predicted_size);