@@ -56,6 +56,8 @@ typedef struct {
56
56
PyObject * missing ;
57
57
} ProfilerObject ;
58
58
59
+ #define ProfilerObject_CAST (op ) ((ProfilerObject *)(op))
60
+
59
61
#define POF_ENABLED 0x001
60
62
#define POF_SUBCALLS 0x002
61
63
#define POF_BUILTINS 0x004
@@ -921,30 +923,32 @@ _lsprof_Profiler_clear_impl(ProfilerObject *self)
921
923
}
922
924
923
925
static int
924
- profiler_traverse (ProfilerObject * op , visitproc visit , void * arg )
926
+ profiler_traverse (PyObject * op , visitproc visit , void * arg )
925
927
{
928
+ ProfilerObject * self = ProfilerObject_CAST (op );
926
929
Py_VISIT (Py_TYPE (op ));
927
- Py_VISIT (op -> externalTimer );
930
+ Py_VISIT (self -> externalTimer );
928
931
return 0 ;
929
932
}
930
933
931
934
static void
932
- profiler_dealloc (ProfilerObject * op )
935
+ profiler_dealloc (PyObject * op )
933
936
{
934
- PyObject_GC_UnTrack (op );
935
- if (op -> flags & POF_ENABLED ) {
937
+ ProfilerObject * self = ProfilerObject_CAST (op );
938
+ PyObject_GC_UnTrack (self );
939
+ if (self -> flags & POF_ENABLED ) {
936
940
PyThreadState * tstate = _PyThreadState_GET ();
937
941
if (_PyEval_SetProfile (tstate , NULL , NULL ) < 0 ) {
938
942
PyErr_FormatUnraisable ("Exception ignored while "
939
943
"destroying _lsprof profiler" );
940
944
}
941
945
}
942
946
943
- flush_unmatched (op );
944
- clearEntries (op );
945
- Py_XDECREF (op -> externalTimer );
946
- PyTypeObject * tp = Py_TYPE (op );
947
- tp -> tp_free (op );
947
+ flush_unmatched (self );
948
+ clearEntries (self );
949
+ Py_XDECREF (self -> externalTimer );
950
+ PyTypeObject * tp = Py_TYPE (self );
951
+ tp -> tp_free (self );
948
952
Py_DECREF (tp );
949
953
}
950
954
@@ -1045,7 +1049,7 @@ _lsprof_clear(PyObject *module)
1045
1049
static void
1046
1050
_lsprof_free (void * module )
1047
1051
{
1048
- _lsprof_clear ((PyObject * )module );
1052
+ ( void ) _lsprof_clear ((PyObject * )module );
1049
1053
}
1050
1054
1051
1055
static int
0 commit comments