File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -75,6 +75,23 @@ TlsfAllocator<T>::TlsfAllocator(const T size)
7575 AddNewBlock (paddedSize, TO_HEADER (data));
7676}
7777
78+ template <typename T>
79+ TlsfAllocator<T>::~TlsfAllocator ()
80+ {
81+ if (data) free (data);
82+
83+ totalBytesRemaining = 0 ;
84+ capacity = 0 ;
85+ bytesRemaining = 0 ;
86+ totalSize = 0 ;
87+
88+ flBitmask = 0 ;
89+
90+ data = nullptr ;
91+ freeList = nullptr ;
92+ slBitmasks = nullptr ;
93+ }
94+
7895template <typename T>
7996void TlsfAllocator<T>::CreateHeader(uint8_t * ptr, const T size, HeaderFlags flags)
8097{
Original file line number Diff line number Diff line change @@ -70,13 +70,19 @@ class TlsfAllocator
7070 * @brief Empty constructor Initialises the constructor and size to 0 (null)
7171 */
7272 TlsfAllocator ();
73+
7374 /* *
7475 * @brief Size initialiser. Accepts a number representing the number of bytes to allocate to
7576 * the allocator's memory buffer
7677 * @param size the number of bytes to allocate, cannot be less than 16
7778 */
7879 TlsfAllocator (const T size);
7980
81+ /* *
82+ * @brief Destructor, deallocates all memory and sets all values to zero
83+ */
84+ ~TlsfAllocator ();
85+
8086 // Deleted copy and move constructors
8187
8288 TlsfAllocator (const TlsfAllocator& other) = delete ;
You can’t perform that action at this time.
0 commit comments