From 49d86527efd5265d835ed5b57e97d5b2a40c6b32 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Wed, 26 Mar 2025 09:32:29 +0000 Subject: [PATCH] Initialize the db_flatfile LoadData stream reference from the ctor. --- modules/database/db_flatfile.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/modules/database/db_flatfile.cpp b/modules/database/db_flatfile.cpp index 4940fce5b..2b2ede625 100644 --- a/modules/database/db_flatfile.cpp +++ b/modules/database/db_flatfile.cpp @@ -40,12 +40,17 @@ class LoadData final : public Serialize::Data { public: - std::fstream *fs = nullptr; + std::fstream *fs; uint64_t id = 0; std::map data; std::stringstream ss; bool read = false; + LoadData(std::fstream &fsref) + : fs(&fsref) + { + } + std::iostream &operator[](const Anope::string &key) override { if (!read) @@ -240,9 +245,7 @@ public: if (buf.find("OBJECT ") == 0) positions[buf.substr(7)].push_back(fd.tellg()); - LoadData ld; - ld.fs = &fd; - + LoadData ld(fd); for (const auto &type_order : Serialize::Type::GetTypeOrder()) { Serialize::Type *stype = Serialize::Type::Find(type_order); @@ -389,9 +392,7 @@ public: return; } - LoadData ld; - ld.fs = &fd; - + LoadData ld(fd); for (Anope::string buf; std::getline(fd, buf.str());) { if (buf == "OBJECT " + stype->GetName())