From: Ebersold Andre Date: Tue, 17 May 2022 09:03:19 +0000 (+0200) Subject: Fixed mog format warning on 64 Bits architecture. Might get the warnings again for... X-Git-Url: https://git.ebersold.fr/?a=commitdiff_plain;h=85385b27293c8790be54b45e8e2dcecde04b5f40;p=aebutils.git Fixed mog format warning on 64 Bits architecture. Might get the warnings again for 32bits --- diff --git a/aeb/pointer/shared_ptr.h b/aeb/pointer/shared_ptr.h index 8ce1c29..e3b36af 100644 --- a/aeb/pointer/shared_ptr.h +++ b/aeb/pointer/shared_ptr.h @@ -32,7 +32,7 @@ class ref_counted { if (m_ref == 0) { - std::cerr<<"HAI"<((p == NULL)?0:1,p); - LOG_SP_DEBUG_FMT("shared_ptr(%0x)::shared_ptr NULL count=%d %x",this,m_counter->count(),m_ptr); + LOG_SP_DEBUG_FMT("shared_ptr(%0lx)::shared_ptr NULL count=%d m_ptr=%lx",(unsigned long)this,m_counter->count(),(unsigned long)m_ptr); //m_counter->add_ref(); } ~shared_ptr() { - LOG_SP_DEBUG_FMT("shared_ptr(%0x)::~shared_ptr count=%d %x",this,m_counter->count(),m_ptr); - if ( m_counter->release() && m_ptr) + LOG_SP_DEBUG_FMT("shared_ptr(%0lx)::~shared_ptr count=%d pointer=%lx",(unsigned long)this,m_counter->count(),(unsigned long)m_ptr); + if ( m_ptr && m_counter->release() ) { - LOG_SP_DEBUG_FMT("shared_ptr(%0x)::~shared_ptr 1 delete m_counter %0x" ,this,m_ptr); - delete m_counter; - LOG_SP_DEBUG_FMT("shared_ptr(%0x)::~shared_ptr 1 delete m_ptr %0x" ,this,m_ptr); + LOG_SP_DEBUG_FMT("shared_ptr(%0lx)::~shared_ptr 1 delete m_counter %0lx" ,(unsigned long)this,(unsigned long)m_ptr); + delete m_counter; m_counter = NULL; + LOG_SP_DEBUG_FMT("shared_ptr(%0lx)::~shared_ptr 1 delete m_ptr %0lx" ,(unsigned long)this,(unsigned long)m_ptr); delete m_ptr; } + if (m_counter) + { + delete m_counter ; m_counter = NULL; + } + } // Copy constructor shared_ptr(const shared_ptr &c) : m_counter(c.m_counter) ,m_ptr(c.m_ptr) { - LOG_SP_DEBUG_FMT("shared_ptr(%0x)::shared_ptr copy count=%d %x",this,m_counter->count(),m_ptr); + LOG_SP_DEBUG_FMT("shared_ptr(%0lx)::shared_ptr copy count=%d %lx",(unsigned long)this,m_counter->count(),(unsigned long)m_ptr); #if 1 - if (m_ptr) + if (m_ptr) + { m_counter->add_ref(); + } else + { // Copy of null pointer ! Should I do sompething with m_counter + } #endif } // Copy operator shared_ptr &operator =(const shared_ptr &rhs) { - LOG_SP_DEBUG_FMT("shared_ptr(%0x)::operator = count=%d m_ptr=%x",this,m_counter->count(),m_ptr); - LOG_SP_DEBUG_FMT("shared_ptr(%0x)::operator = rsh count=%d m_ptr=%x",this,rhs.m_counter->count(),rhs.m_ptr); + LOG_SP_DEBUG_FMT("shared_ptr(%0lx)::operator = count=%d m_ptr=%lx",(unsigned long)this,m_counter->count(),(unsigned long)m_ptr); + LOG_SP_DEBUG_FMT("shared_ptr(%0lx)::operator = rsh count=%d m_ptr=%lx",(unsigned long)this,rhs.m_counter->count(),(unsigned long)rhs.m_ptr); if (this != &rhs) { - LOG_SP_DEBUG_FMT("shared_ptr::operator = this(%0x) != &rhs(%0x)" ,this,&rhs); + LOG_SP_DEBUG_FMT("shared_ptr::operator = this(%0lx) != &rhs(%0lx)" ,(unsigned long)this,(unsigned long)&rhs); // Free pointer I owned if ( m_counter->count() && m_counter->release() ) { - LOG_SP_DEBUG_FMT("shared_ptr::operator = this(%0x) delete counter %0x" ,this,m_counter); + LOG_SP_DEBUG_FMT("shared_ptr::operator = this(%0lx) delete counter %0lx" ,(unsigned long)this,(unsigned long)m_counter); delete m_counter; - LOG_SP_DEBUG_FMT("shared_ptr::operator = this(%0x) delete m_ptr %0x" ,this,m_ptr); + LOG_SP_DEBUG_FMT("shared_ptr::operator = this(%0lx) delete m_ptr %0lx" ,(unsigned long)this,(unsigned long)m_ptr); delete m_ptr; m_ptr = NULL; } else { - LOG_SP_DEBUG_FMT("shared_ptr::operator = this(%0x) delete m_counter %0x" ,this,m_counter); + LOG_SP_DEBUG_FMT("shared_ptr::operator = this(%0lx) delete m_counter %0lx" ,(unsigned long)this,(unsigned long)m_counter); delete m_counter; // Not sure if this is needed if (m_ptr != NULL) { - LOG_SP_DEBUG_FMT("shared_ptr::operator = this(%0x) 1 delete m_ptr %0x" ,this,m_ptr); + LOG_SP_DEBUG_FMT("shared_ptr::operator = this(%0lx) 1 delete m_ptr %0lx" ,(unsigned long)this,(unsigned long)m_ptr); delete m_ptr; m_ptr = NULL; }