diff --git a/xbob/math/cleanup.h b/xbob/math/cleanup.h deleted file mode 100644 index d6f0011fece2edffea89ac756732595a3f2caefd..0000000000000000000000000000000000000000 --- a/xbob/math/cleanup.h +++ /dev/null @@ -1,37 +0,0 @@ -/** - * @author Andre Anjos <andre.anjos@idiap.ch> - * @date Wed 11 Dec 08:42:53 2013 - * - * @brief Some C++ tricks to make our life dealing with Python references a bit - * easier - */ - -#include <Python.h> -#include <memory> - -/** - * Calls Py_DECREF(x) on the input object x. Usage pattern: - * - * PyObject* x = ... // builds x with a new python reference - * auto protected_x = make_safe(x); - * - * After this point, no need to worry about DECREF'ing x anymore. - * You can still use `x' inside your code, or protected_x.get(). - */ -template <typename T> std::shared_ptr<T> make_safe(T* o) { - return std::shared_ptr<T>(o, [&](T* p){Py_DECREF(p);}); -} - -/** - * Calls Py_XDECREF(x) on the input object x. Usage pattern: - * - * PyObject* x = ... // builds x with a new python reference, x may be NULL - * auto protected_x = make_xsafe(x); - * - * After this point, no need to worry about XDECREF'ing x anymore. - * You can still use `x' inside your code, or protected_x.get(). Note - * `x' may be NULL with this method. - */ -template <typename T> std::shared_ptr<T> make_xsafe(T* o) { - return std::shared_ptr<T>(o, [&](T* p){Py_XDECREF(p);}); -} diff --git a/xbob/math/histogram.cpp b/xbob/math/histogram.cpp index 27f5e5766f4e81cc15013a61c0e58bae7919ecc9..6126e1e82e836c9aa680b3a1b6054eef866c5ff5 100644 --- a/xbob/math/histogram.cpp +++ b/xbob/math/histogram.cpp @@ -8,9 +8,9 @@ * Copyright (C) 2011-2013 Idiap Research Institute, Martigny, Switzerland */ -#include "cleanup.h" #include "histogram.h" #include <xbob.blitz/cppapi.h> +#include <xbob.blitz/cleanup.h> #include "bob/math/histogram.h" static PyObject* py_histogram_intersection_1 diff --git a/xbob/math/linsolve.cpp b/xbob/math/linsolve.cpp index 5adb11a14dd3c5437ba728a7c85a3673541cb3f7..d1b7b6a14cf5b3a0f9e505211a581ecec567aa7e 100644 --- a/xbob/math/linsolve.cpp +++ b/xbob/math/linsolve.cpp @@ -8,9 +8,9 @@ * Copyright (C) 2011-2013 Idiap Research Institute, Martigny, Switzerland */ -#include "cleanup.h" #include "histogram.h" #include <xbob.blitz/cppapi.h> +#include <xbob.blitz/cleanup.h> #include "bob/math/linsolve.h" static PyObject* py_linsolve_1(PyObject*, PyObject* args, PyObject* kwds) { diff --git a/xbob/math/lp_interior_point.cpp b/xbob/math/lp_interior_point.cpp index 59ab057c43c0bc2646c46f4fc5db887720a72aa8..1750a2a2288cc6f491d39d794020007708f5118f 100644 --- a/xbob/math/lp_interior_point.cpp +++ b/xbob/math/lp_interior_point.cpp @@ -9,9 +9,9 @@ * Copyright (C) 2011-2013 Idiap Research Institute, Martigny, Switzerland */ -#include "cleanup.h" #include "lp_interior_point.h" #include <xbob.blitz/cppapi.h> +#include <xbob.blitz/cleanup.h> #include <bob/math/LPInteriorPoint.h> #include <structmember.h> diff --git a/xbob/math/pavx.cpp b/xbob/math/pavx.cpp index f1ca2471d823fc1e6f78d8f2f2ea4ea5700c60f9..00f5f0d22aa1e2a6f037be403da9e510def5488a 100644 --- a/xbob/math/pavx.cpp +++ b/xbob/math/pavx.cpp @@ -6,9 +6,9 @@ * @brief Binds the Pool-Adjacent-Violators Algorithm */ -#include "cleanup.h" #include "pavx.h" #include <xbob.blitz/cppapi.h> +#include <xbob.blitz/cleanup.h> #include "bob/math/pavx.h" #include "bob/core/cast.h" diff --git a/xbob/math/scatter.cpp b/xbob/math/scatter.cpp index 1fdf3224b76d585543c3f2ab5f333aceeb9537d1..73d0ec921cdd8e6558b9138f13071e22568477f1 100644 --- a/xbob/math/scatter.cpp +++ b/xbob/math/scatter.cpp @@ -7,9 +7,9 @@ * Copyright (C) 2011-2013 Idiap Research Institute, Martigny, Switzerland */ -#include "cleanup.h" #include "scatter.h" #include <xbob.blitz/cppapi.h> +#include <xbob.blitz/cleanup.h> #include <bob/math/stats.h> PyObject* py_scatter (PyObject*, PyObject* args, PyObject* kwds) {