From 078585db28da772b7cb1d8f31f7198f83463483e Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Mon, 21 Jan 2002 06:20:15 +0000 Subject: [PATCH] fixed transfer-of-ownership counting to avoid problems [SVN r12392] --- include/boost/python/reference.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/boost/python/reference.hpp b/include/boost/python/reference.hpp index f0cdab55..97edef99 100644 --- a/include/boost/python/reference.hpp +++ b/include/boost/python/reference.hpp @@ -173,10 +173,10 @@ public: void reset(T2* x, increment_count_t) { assert(m_p == 0 || m_p->ob_refcnt > 0); + Py_XINCREF(x); Py_XDECREF(m_p); m_p = expect_non_null(x); assert(m_p->ob_refcnt > 0); - Py_INCREF(m_p); } template @@ -192,20 +192,20 @@ public: void reset(T2* x, allow_null, increment_count_t) { assert(m_p == 0 || m_p->ob_refcnt > 0); + Py_XINCREF(x); Py_XDECREF(m_p); m_p = x; assert(m_p == 0 || m_p->ob_refcnt > 0); - Py_XINCREF(m_p); } template void reset(T2* x, increment_count_t, allow_null) { assert(m_p == 0 || m_p->ob_refcnt > 0); + Py_XINCREF(x); Py_XDECREF(m_p); m_p = x; assert(m_p == 0 || m_p->ob_refcnt > 0); - Py_XINCREF(m_p); } #if !defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS)