Skip to content

Commit 2ffd264

Browse files
Merge pull request #4601 from pan-/fix_memory_pool_destructor
rtos: Fix MemoryPool and Queue destructor
2 parents 041737b + e690ee0 commit 2ffd264

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

rtos/MemoryPool.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ class MemoryPool : private mbed::NonCopyable<MemoryPool<T, pool_sz> > {
5858
MBED_ASSERT(_id);
5959
}
6060

61+
/** Destroy a memory pool */
62+
~MemoryPool() {
63+
osMemoryPoolDelete(_id);
64+
}
65+
6166
/** Allocate a memory block of type T from a memory pool.
6267
@return address of the allocated memory block or NULL in case of no memory available.
6368
*/

rtos/Queue.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ class Queue : private mbed::NonCopyable<Queue<T, queue_sz> > {
6060
MBED_ASSERT(_id);
6161
}
6262

63+
~Queue() {
64+
osMessageQueueDelete(_id);
65+
}
66+
6367
/** Put a message in a Queue.
6468
@param data message pointer.
6569
@param millisec timeout value or 0 in case of no time-out. (default: 0)

0 commit comments

Comments
 (0)