Re: Custom memory manager and calling unref for Cairo::RefPtr<Cairo::Context>



Sorry it took so long to reply.

the pCppRefcount_ member is not allocated in cairo, it is allocated using 'new' (see line 228: http://cgit.freedesktop.org/cairomm/tree/cairomm/refptr.h#228).  Since it's defined in a header, it should be using your custom new operator.  I just did a very crude test and i was able to override new and delete and both the creation and deletion of the pCppRefcount_ member used my custom allocation functions.  Is it possible that your custom allocator has a bug?
Jonner

Thank for reply. Yes you right,  pCppRefcount_ is allocated by my custom 'new', but please take a look at line 286
template <class T_CppObject> inline
RefPtr<T_CppObject>& RefPtr<T_CppObject>::operator=(const RefPtr<T_CppObject>& src)
{
  RefPtr<T_CppObject> temp (src);
  this->swap(temp);
  return *this;
}
 
As I understand  pCppRefcount_ and pCppObject_ will be swaped with  values returned from create_cairo_context function.
It is really strange why pCppObject_ can be deleted, but pCppRefcount_ not.

Is it possible that your custom allocator has a bug?

This is well known nedmalloc allocator.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]