[C++-sig] call policies help needed

David Abrahams dave at boost-consulting.com
Tue Dec 6 21:40:41 CET 2005

Ricardo Kirkner <ricardokirkner at gmail.com> writes:

>  hi. I am trying to wrap a method that returns a new object (allocated
> with new)). As far as I know, I have to use the
> return_value_policy<manage_new_object>() construct, to tell the
> wrapper to hold that pointer.
> The wrapper compiles ok, but when I call that method (from python) I
> get an error (from glib) and the python interpreter exits. What am I
> missing?

It's unclear.  Are you *certain* this object was allocated with new?
If that's the case, I can't imagine that the problem is coming from
that particular wrapped function.  My advice (as usual) is to reduce
your program to the simplest possible case that still exhibits the
problem.  That almost always immediately reveals the problem.  I hear
utilities like valgrind can be really useful for situations like this,
too, though I've never used it myself.

Dave Abrahams
Boost Consulting

More information about the Cplusplus-sig mailing list