@@ -42,7 +42,7 @@ class zone {
4242 finalizer* fin = m_head;
4343 finalizer* tmp = nullptr ;
4444 while (fin) {
45- (*( fin- 1 ) )();
45+ (*fin)();
4646 if (clear) {
4747 tmp = fin;
4848 }
@@ -53,10 +53,11 @@ class zone {
5353 }
5454 }
5555 ~finalizer_array () {
56- call ( true );
56+ clear ( );
5757 }
5858 void clear () {
5959 call (true );
60+ m_head = MSGPACK_NULLPTR;
6061 }
6162 void push (void (*func)(void * data), void* data)
6263 {
@@ -68,13 +69,13 @@ class zone {
6869 m_head = n;
6970 }
7071
72+
7173 finalizer_array (finalizer_array&& other) noexcept : m_head(other.m_head) {
7274 other.m_head = MSGPACK_NULLPTR;
7375 }
74- finalizer_array& operator =(finalizer_array&& other) noexcept
75- {
76- this ->~finalizer_array ();
77- new (this ) finalizer_array (std::move (other));
76+ finalizer_array& operator =(finalizer_array&& other) noexcept {
77+ m_head = other.m_head ;
78+ other.m_head = MSGPACK_NULLPTR;
7879 return *this ;
7980 }
8081 finalizer* m_head;
@@ -95,6 +96,7 @@ class zone {
9596 ::free (c);
9697 c = n;
9798 }
99+ m_head = MSGPACK_NULLPTR;
98100 }
99101 void clear (size_t chunk_size, char * ptr)
100102 {
@@ -187,6 +189,7 @@ inline zone::zone(size_t chunk_size):m_chunk_size(chunk_size), m_chunk_list(MSGP
187189
188190inline zone::~zone ()
189191{
192+ m_finalizer_array.~finalizer_array ();
190193 if (m_chunk_list) {
191194 m_chunk_list->~chunk_list ();
192195 ::free (m_chunk_list);
@@ -198,9 +201,9 @@ inline char* zone::get_aligned(char* ptr, size_t align)
198201{
199202 MSGPACK_ASSERT (align != 0 && (align & (align - 1 )) == 0 ); // align must be 2^n (n >= 0)
200203 return
201- reinterpret_cast <char *>(
202- reinterpret_cast <uintptr_t >(ptr + (align - 1 )) & ~static_cast <uintptr_t >(align - 1 )
203- );
204+ reinterpret_cast <char *>(
205+ reinterpret_cast <uintptr_t >(ptr + (align - 1 )) & ~static_cast <uintptr_t >(align - 1 )
206+ );
204207}
205208
206209inline zone::chunk_list& zone::get_chank_lst ()
0 commit comments