/* Forward declaration (for atexit_cleanup) */
static PyObject *atexit_clear(PyObject*);
+/* Forward declaration (for atexit_callfuncs) */
+static void atexit_cleanup(void);
/* ===================================================================== */
/* Callback machinery. */
/* Installed into pythonrun.c's atexit mechanism */
-void
+static void
atexit_callfuncs(void)
{
PyObject *exc_type = NULL, *exc_value, *exc_tb, *r;
}
}
+ atexit_cleanup();
+
if (exc_type)
PyErr_Restore(exc_type, exc_value, exc_tb);
}
-void
+static void
atexit_delete_cb(int i)
{
atexit_callback *cb = atexit_callbacks[i];
PyMem_Free(cb);
}
-void
+static void
atexit_cleanup(void)
{
PyObject *r = atexit_clear(NULL);
return NULL;
_Py_PyAtExit(atexit_callfuncs);
- /* Register a callback that will free
- atexit_callbacks, otherwise valgrind will report memory leaks. */
- Py_AtExit(atexit_cleanup);
return m;
}