Logo Search packages:      
Sourcecode: djvulibre version File versions  Download package

GPBase & GPBase::assign ( const GPBase sptr  )  [inherited]

Assignment from smartpointer. Increments the counter of the new value of the pointer. Decrements the counter of the previous value of the pointer.

Definition at line 162 of file GSmartPointer.cpp.

References GPEnabled::count, GPEnabled::destroy(), and GPBase::ptr.

Referenced by GPBase::GPBase(), GP< TYPE >::operator=(), and GPBase::operator=().

{
  gcsCounter.lock();
  if (sptr.ptr) 
    {
      sptr.ptr->count++;
    }
  if (ptr)
    {
      GPEnabled *old = ptr;
      ptr = sptr.ptr;
      if (! --old->count) 
        old->count = -1;
      gcsCounter.unlock();      
      if (old->count < 0)
        old->destroy();
    }
  else
    {
      ptr = sptr.ptr;
      gcsCounter.unlock();
    }
  return *this;
}


Generated by  Doxygen 1.6.0   Back to index