From df3469efbad837da510aca81164e8f2b58cfc46b Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sat, 28 Jun 2025 09:48:58 -0500 Subject: [PATCH] dry --- esphome/core/scheduler.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/esphome/core/scheduler.h b/esphome/core/scheduler.h index 3c23aace62..0d1dc45d52 100644 --- a/esphome/core/scheduler.h +++ b/esphome/core/scheduler.h @@ -86,11 +86,19 @@ class Scheduler { // Destructor to clean up dynamic names ~SchedulerItem() { - if (owns_name && name_.dynamic_name) { + if (owns_name) { delete[] name_.dynamic_name; } } + // Delete copy operations to prevent accidental copies + SchedulerItem(const SchedulerItem &) = delete; + SchedulerItem &operator=(const SchedulerItem &) = delete; + + // Default move operations + SchedulerItem(SchedulerItem &&) = default; + SchedulerItem &operator=(SchedulerItem &&) = default; + // Helper to get the name regardless of storage type const char *get_name() const { return owns_name ? name_.dynamic_name : name_.static_name; }