Smart pointers and memory management cleanup (#10400)

* Refactor memory management in Syslog and StoreForwardModule

* Implement destructor for Lock

* Refactor RotaryEncoder and PacketHistory to use smart pointers for better memory management

* CH341 should use unique_ptr for improved memory management

* Fix checks in PH

* Improve Syslog::vlogf to handle variable argument lists more safely

* Fix initOk method to use nullptr for null pointer check
This commit is contained in:
Ben Meadors
2026-05-06 15:33:59 -05:00
committed by GitHub
co-authored by GitHub
parent 6e810741f3
commit 220bb4d186
10 changed files with 68 additions and 71 deletions
+4 -4
View File
@@ -18,6 +18,7 @@
#include <fstream>
#include <iostream>
#include <map>
#include <memory>
#include <set>
#include <stdexcept>
#include <sys/ioctl.h>
@@ -297,10 +298,9 @@ void portduinoSetup()
// Try CH341
try {
std::cout << "autoconf: Looking for CH341 device..." << std::endl;
ch341Hal = new Ch341Hal(0, portduino_config.lora_usb_serial_num, portduino_config.lora_usb_vid,
portduino_config.lora_usb_pid);
ch341Hal->getProductString(autoconf_product, 95);
delete ch341Hal;
auto probe = std::unique_ptr<Ch341Hal>(new Ch341Hal(0, portduino_config.lora_usb_serial_num,
portduino_config.lora_usb_vid, portduino_config.lora_usb_pid));
probe->getProductString(autoconf_product, 95);
std::cout << "autoconf: Found CH341 device " << autoconf_product << std::endl;
found_ch341 = true;