Commit b780503d authored by Ronan's avatar Ronan Committed by Ronan

fix(wrapper): in cpp wrapper do not conserve the taken ref of c object when it...

fix(wrapper): in cpp wrapper do not conserve the taken ref of c object when it exists a cpp shared object
parent 3792f8c5
......@@ -59,6 +59,10 @@ void *linphone::Object::sharedPtrToCPtr(const std::shared_ptr< const linphone::O
else return sharedPtr->mPrivPtr;
}
void linphone::Object::unrefCPtr(void *ptr) {
belle_sip_object_unref(ptr);
}
static void deleteCppUserDataMap(std::map<std::string,void *> *userDataMap) {
delete userDataMap;
}
......
......@@ -81,25 +81,18 @@ namespace linphone {
if (cppPtr == NULL) {
return std::make_shared<T>(ptr, takeRef);
} else {
if (!takeRef) unrefCPtr(ptr);
return std::static_pointer_cast<T,Object>(cppPtr->shared_from_this());
}
}
}
template <class T>
static std::shared_ptr<const T> cPtrToSharedPtr(const void *ptr, bool takeRef=true) {
if (ptr == NULL) {
return nullptr;
} else {
Object *cppPtr = getBackPtrFromCPtr(ptr);
if (cppPtr == NULL) {
return std::make_shared<const T>((void *)ptr, takeRef);
} else {
return std::static_pointer_cast<const T,Object>(cppPtr->shared_from_this());
}
}
return cPtrToSharedPtr<T>(const_cast<void *>(ptr), takeRef);
}
static void *sharedPtrToCPtr(const std::shared_ptr<const Object> &sharedPtr);
static void unrefCPtr(void *ptr);
private:
LINPHONECXX_PUBLIC std::map<std::string,void *> &getUserData() const;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment