Commit ca7c1b6d authored by Kirill Smelkov's avatar Kirill Smelkov

bigfile/py: Factor outcode to get list of objects that refer to obj to XPyObject_GetReferrers()

We'll need it in next patch to get and analyze this list.
parent 20b41a5a
...@@ -120,6 +120,9 @@ static void XPyErr_SetFromErrno(void); ...@@ -120,6 +120,9 @@ static void XPyErr_SetFromErrno(void);
* everything else related to exception state */ * everything else related to exception state */
static void XPyErr_FullClear(void); static void XPyErr_FullClear(void);
/* get list of objects that refer to obj */
static PyObject* /* PyListObject* */ XPyObject_GetReferrers(PyObject *obj);
/* print objects that refer to obj */ /* print objects that refer to obj */
static void XPyObject_PrintReferrers(PyObject *obj, FILE *fp); static void XPyObject_PrintReferrers(PyObject *obj, FILE *fp);
...@@ -976,11 +979,19 @@ XPyErr_FullClear(void) ...@@ -976,11 +979,19 @@ XPyErr_FullClear(void)
PySys_SetObject("exc_traceback", Py_None); PySys_SetObject("exc_traceback", Py_None);
} }
static void static PyObject* /* PyListObject* */
XPyObject_PrintReferrers(PyObject *obj, FILE *fp) XPyObject_GetReferrers(PyObject *obj)
{ {
PyObject *obj_referrers = PyObject_CallMethod(gcmodule, "get_referrers", "O", obj); PyObject *obj_referrers = PyObject_CallMethod(gcmodule, "get_referrers", "O", obj);
BUG_ON(!obj_referrers); BUG_ON(!obj_referrers);
BUG_ON(!PyList_CheckExact(obj_referrers));
return /*(PyListObject *)*/obj_referrers;
}
static void
XPyObject_PrintReferrers(PyObject *obj, FILE *fp)
{
PyObject *obj_referrers = XPyObject_GetReferrers(obj);
PyObject_Print(obj_referrers, fp, 0); PyObject_Print(obj_referrers, fp, 0);
Py_DECREF(obj_referrers); Py_DECREF(obj_referrers);
} }
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