Skip to content

Add virtual destructor to classes #1910

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions hal/api/AnalogIn.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ class AnalogIn {
}
#endif

virtual ~AnalogIn() {
// Do nothing
}

protected:

virtual void lock() {
Expand Down
4 changes: 4 additions & 0 deletions hal/api/AnalogOut.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ class AnalogOut {
}
#endif

virtual ~AnalogOut() {
// Do nothing
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this comment do nothing is redundant in all of them?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wanted to indicate that the code was not forgotten accidentally. Want me to remove it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

}

protected:

virtual void lock() {
Expand Down
4 changes: 4 additions & 0 deletions hal/api/I2C.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ class I2C {
*/
virtual void unlock(void);

virtual ~I2C() {
// Do nothing
}

#if DEVICE_I2C_ASYNCH

/** Start non-blocking I2C transfer.
Expand Down
7 changes: 3 additions & 4 deletions hal/api/InterruptManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,13 @@ class InterruptManager {
*/
bool remove_handler(pFunctionPointer_t handler, IRQn_Type irq);

protected:
virtual void lock();
virtual void unlock();

private:
InterruptManager();
~InterruptManager();

void lock();
void unlock();

// We declare the copy contructor and the assignment operator, but we don't
// implement them. This way, if someone tries to copy/assign our instance,
// he will get an error at compile time.
Expand Down