Make Downloader return shared_ptr instead of raw pointer.

This is dangerous by nature to return raw pointer on internal data.
This commit is contained in:
Matthieu Gautier
2023-02-07 10:55:57 +01:00
parent 52ae5c3a5f
commit 0e612de4d1
2 changed files with 13 additions and 13 deletions

View File

@ -93,15 +93,15 @@ class Downloader
void close();
Download* startDownload(const std::string& uri, const std::vector<std::pair<std::string, std::string>>& options = {});
Download* getDownload(const std::string& did);
std::shared_ptr<Download> startDownload(const std::string& uri, const std::vector<std::pair<std::string, std::string>>& options = {});
std::shared_ptr<Download> getDownload(const std::string& did);
size_t getNbDownload();
std::vector<std::string> getDownloadIds();
private:
std::mutex m_lock;
std::map<std::string, std::unique_ptr<Download>> m_knownDownloads;
std::map<std::string, std::shared_ptr<Download>> m_knownDownloads;
std::shared_ptr<Aria2> mp_aria;
};
}