Skip to content

Commit 58d15f3

Browse files
committed
Add virtual destructor to classes
Add a virtual destructor to classes which have a virtual lock and unlock. Remove the virtual qualifier from functions in InterruptManager since this class cannot be extended.
1 parent 95c8393 commit 58d15f3

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed

hal/api/AnalogIn.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ class AnalogIn {
103103
}
104104
#endif
105105

106+
virtual ~AnalogIn() {
107+
// Do nothing
108+
}
109+
106110
protected:
107111

108112
virtual void lock() {

hal/api/AnalogOut.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ class AnalogOut {
122122
}
123123
#endif
124124

125+
virtual ~AnalogOut() {
126+
// Do nothing
127+
}
128+
125129
protected:
126130

127131
virtual void lock() {

hal/api/I2C.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,10 @@ class I2C {
145145
*/
146146
virtual void unlock(void);
147147

148+
virtual ~I2C() {
149+
// Do nothing
150+
}
151+
148152
#if DEVICE_I2C_ASYNCH
149153

150154
/** Start non-blocking I2C transfer.

hal/api/InterruptManager.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,13 @@ class InterruptManager {
113113
*/
114114
bool remove_handler(pFunctionPointer_t handler, IRQn_Type irq);
115115

116-
protected:
117-
virtual void lock();
118-
virtual void unlock();
119-
120116
private:
121117
InterruptManager();
122118
~InterruptManager();
123119

120+
void lock();
121+
void unlock();
122+
124123
// We declare the copy contructor and the assignment operator, but we don't
125124
// implement them. This way, if someone tries to copy/assign our instance,
126125
// he will get an error at compile time.

0 commit comments

Comments
 (0)