Do not store raw pointer to NameMapper.

While it was "ok" to store raw pointer as, in our use case, the nameMapper
always live longer than object using it; it is not safe to store
raw pointer on object than may be deleted.

All classes storing a NameMapper now store a shared_ptr.
Functions only using the library (as `HumanReadableNameMapper`) continue
to use a (const) reference.
This commit is contained in:
Matthieu Gautier
2022-10-07 11:11:20 +02:00
parent 4842fa0355
commit 3d75f24a29
8 changed files with 15 additions and 15 deletions

View File

@ -42,7 +42,7 @@ class OPDSDumper
{
public:
OPDSDumper() = default;
OPDSDumper(std::shared_ptr<Library> library, NameMapper* NameMapper);
OPDSDumper(std::shared_ptr<Library> library, std::shared_ptr<NameMapper> NameMapper);
~OPDSDumper();
/**
@ -111,7 +111,7 @@ class OPDSDumper
protected:
std::shared_ptr<kiwix::Library> library;
kiwix::NameMapper* nameMapper;
std::shared_ptr<kiwix::NameMapper> nameMapper;
std::string libraryId;
std::string rootLocation;
int m_totalResults;