TFTDisplay destructor

This commit is contained in:
Ben Meadors 2025-09-05 06:22:21 -05:00
parent 68f07c5f9d
commit 3df3c876cc
2 changed files with 12 additions and 0 deletions

View File

@ -1128,6 +1128,15 @@ TFTDisplay::TFTDisplay(uint8_t address, int sda, int scl, OLEDDISPLAY_GEOMETRY g
#endif
}
TFTDisplay::~TFTDisplay()
{
// Clean up allocated line pixel buffer to prevent memory leak
if (linePixelBuffer != nullptr) {
free(linePixelBuffer);
linePixelBuffer = nullptr;
}
}
// Write the buffer to the display memory
void TFTDisplay::display(bool fromBlank)
{

View File

@ -20,6 +20,9 @@ class TFTDisplay : public OLEDDisplay
*/
TFTDisplay(uint8_t, int, int, OLEDDISPLAY_GEOMETRY, HW_I2C);
// Destructor to clean up allocated memory
~TFTDisplay();
// Write the buffer to the display memory
virtual void display() override { display(false); };
virtual void display(bool fromBlank);