Fixed memory problems

This commit is contained in:
2026-06-25 16:04:56 +03:00
parent 84bc7f5d40
commit eca47d1596
3 changed files with 45 additions and 62 deletions

11
TRMNL.h
View File

@@ -9,6 +9,8 @@
#include "json.hpp"
constexpr int DEFAULT_REFRESH_RATE = 300;
class TRMNL
{
private:
@@ -20,11 +22,13 @@ private:
std::function<void (const TRMNL& trmnl)> m_update_handler;
public:
// Constructor
// Constructors
TRMNL(const std::string& id = "",
const std::string& api_key = "",
const std::string& friendly_id = "",
int refresh_rate = 600);
int refresh_rate = DEFAULT_REFRESH_RATE);
TRMNL(const nlohmann::json& j);
// Getters
const std::string& id() const;
@@ -43,7 +47,6 @@ public:
static std::string friendly_from_id(std::string id);
friend void to_json(nlohmann::json& j, const TRMNL& trmnl);
friend void from_json(const nlohmann::json& j, TRMNL& trmnl);
friend class TRMNLContainer;
};
@@ -58,6 +61,7 @@ private:
public:
TRMNLContainer() = default;
TRMNLContainer& operator=(const TRMNLContainer& other);
void add_device(TRMNL trmnl);
@@ -67,7 +71,6 @@ public:
void clear();
friend void to_json(nlohmann::json& j, const TRMNLContainer& cont);
friend void from_json(const nlohmann::json& j, TRMNLContainer& cont);
};
#endif // TRMNL_H_