@@ -622,7 +622,7 @@ bool named_plot(const std::string& name, const std::vector<Numeric>& y, const st
622622
623623 Py_DECREF (kwargs);
624624 Py_DECREF (plot_args);
625- if (res) Py_DECREF (res);
625+ if (res) Py_DECREF (res);
626626
627627 return res;
628628}
@@ -647,7 +647,7 @@ bool named_plot(const std::string& name, const std::vector<Numeric>& x, const st
647647
648648 Py_DECREF (kwargs);
649649 Py_DECREF (plot_args);
650- if (res) Py_DECREF (res);
650+ if (res) Py_DECREF (res);
651651
652652 return res;
653653}
@@ -672,7 +672,7 @@ bool named_semilogx(const std::string& name, const std::vector<Numeric>& x, cons
672672
673673 Py_DECREF (kwargs);
674674 Py_DECREF (plot_args);
675- if (res) Py_DECREF (res);
675+ if (res) Py_DECREF (res);
676676
677677 return res;
678678}
@@ -697,7 +697,7 @@ bool named_semilogy(const std::string& name, const std::vector<Numeric>& x, cons
697697
698698 Py_DECREF (kwargs);
699699 Py_DECREF (plot_args);
700- if (res) Py_DECREF (res);
700+ if (res) Py_DECREF (res);
701701
702702 return res;
703703}
@@ -722,7 +722,7 @@ bool named_loglog(const std::string& name, const std::vector<Numeric>& x, const
722722
723723 Py_DECREF (kwargs);
724724 Py_DECREF (plot_args);
725- if (res) Py_DECREF (res);
725+ if (res) Py_DECREF (res);
726726
727727 return res;
728728}
@@ -853,7 +853,8 @@ inline void title(const std::string &titlestr)
853853 PyObject* res = PyObject_CallObject (detail::_interpreter::get ().s_python_function_title , args);
854854 if (!res) throw std::runtime_error (" Call to title() failed." );
855855
856- // if PyDeCRFF, the function doesn't work on Mac OS
856+ Py_DECREF (args);
857+ Py_DECREF (res);
857858}
858859
859860inline void axis (const std::string &axisstr)
@@ -865,7 +866,8 @@ inline void axis(const std::string &axisstr)
865866 PyObject* res = PyObject_CallObject (detail::_interpreter::get ().s_python_function_axis , args);
866867 if (!res) throw std::runtime_error (" Call to title() failed." );
867868
868- // if PyDeCRFF, the function doesn't work on Mac OS
869+ Py_DECREF (args);
870+ Py_DECREF (res);
869871}
870872
871873inline void xlabel (const std::string &str)
@@ -877,7 +879,8 @@ inline void xlabel(const std::string &str)
877879 PyObject* res = PyObject_CallObject (detail::_interpreter::get ().s_python_function_xlabel , args);
878880 if (!res) throw std::runtime_error (" Call to xlabel() failed." );
879881
880- // if PyDeCRFF, the function doesn't work on Mac OS
882+ Py_DECREF (args);
883+ Py_DECREF (res);
881884}
882885
883886inline void ylabel (const std::string &str)
@@ -889,20 +892,23 @@ inline void ylabel(const std::string &str)
889892 PyObject* res = PyObject_CallObject (detail::_interpreter::get ().s_python_function_ylabel , args);
890893 if (!res) throw std::runtime_error (" Call to ylabel() failed." );
891894
892- // if PyDeCRFF, the function doesn't work on Mac OS
895+ Py_DECREF (args);
896+ Py_DECREF (res);
893897}
894898
895899inline void grid (bool flag)
896900{
897901 PyObject* pyflag = flag ? Py_True : Py_False;
902+ Py_INCREF (pyflag);
898903
899904 PyObject* args = PyTuple_New (1 );
900905 PyTuple_SetItem (args, 0 , pyflag);
901906
902907 PyObject* res = PyObject_CallObject (detail::_interpreter::get ().s_python_function_grid , args);
903908 if (!res) throw std::runtime_error (" Call to grid() failed." );
904909
905- // if PyDeCRFF, the function doesn't work on Mac OS
910+ Py_DECREF (args);
911+ Py_DECREF (res);
906912}
907913
908914inline void show (const bool block = true )
@@ -919,6 +925,7 @@ inline void show(const bool block = true)
919925 PyObject *kwargs = PyDict_New ();
920926 PyDict_SetItemString (kwargs, " block" , Py_False);
921927 res = PyObject_Call ( detail::_interpreter::get ().s_python_function_show , detail::_interpreter::get ().s_python_empty_tuple , kwargs);
928+ Py_DECREF (kwargs);
922929 }
923930
924931
@@ -945,6 +952,8 @@ inline void xkcd() {
945952 res = PyObject_Call (detail::_interpreter::get ().s_python_function_xkcd ,
946953 detail::_interpreter::get ().s_python_empty_tuple , kwargs);
947954
955+ Py_DECREF (kwargs);
956+
948957 if (!res)
949958 throw std::runtime_error (" Call to show() failed." );
950959
@@ -1112,8 +1121,6 @@ struct plot_impl<std::true_type>
11121121 template <typename Iterable, typename Callable>
11131122 bool operator ()(const Iterable& ticks, const Callable& f, const std::string& format)
11141123 {
1115- // std::cout << "Callable impl called" << std::endl;
1116-
11171124 if (begin (ticks) == end (ticks)) return true ;
11181125
11191126 // We could use additional meta-programming to deduce the correct element type of y,
0 commit comments