Skip to content

Commit f5fcd38

Browse files
committed
Use delete[]
1 parent 215bc1e commit f5fcd38

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/qwiic_oled_custom.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,11 @@ class QwOLEDCustom : public QwGrSSD1306 {
7878
default_address = kOLEDCustomDefaultDefaultAddress;
7979
};
8080

81-
~QwOLEDCustom(){if (m_graphicsBuffer != nullptr) delete m_graphicsBuffer;};
81+
~QwOLEDCustom()
82+
{
83+
if (m_graphicsBuffer != nullptr)
84+
delete[] m_graphicsBuffer;
85+
};
8286

8387
// set up the specific device settings
8488
bool init(void)
@@ -90,8 +94,9 @@ class QwOLEDCustom : public QwGrSSD1306 {
9094
setVcomDeselect(vcomDeselect);
9195
setContrast(contrast);
9296

93-
if (m_graphicsBuffer == nullptr)
94-
m_graphicsBuffer = new uint8_t[(uint16_t)displayWidth * (uint16_t)displayHeight / 8];
97+
if (m_graphicsBuffer != nullptr)
98+
delete[] m_graphicsBuffer;
99+
m_graphicsBuffer = new uint8_t[(uint16_t)displayWidth * (uint16_t)displayHeight / 8];
95100
setBuffer(m_graphicsBuffer); // The buffer to use
96101

97102
// Call the super class to do all the work

0 commit comments

Comments
 (0)