@@ -47,36 +47,41 @@ new_weakref(PyObject *ob, PyObject *callback)
47
47
48
48
49
49
/* This function is responsible for clearing the callback slot. When using this
50
- * It must be called before calling remove_weakref, otherwise a segmentation fault will
51
- * occur at build time.
50
+ * function it must be called before calling remove_weakref_from_referent,
51
+ * otherwise a segmentation fault will occur at build time.
52
52
*/
53
53
static void
54
54
clear_weakref (PyWeakReference * self )
55
55
{
56
56
PyObject * callback = self -> wr_callback ;
57
+
57
58
if (callback != NULL ) {
58
59
Py_DECREF (callback );
59
60
self -> wr_callback = NULL ;
60
61
}
61
62
}
62
63
63
- /* This function removes the pass in reference from the list of weak references
64
- * for the referent. This should be called from remove_weakref_fromt_referent
65
- * as it will pass the required list argument.
64
+ /* This function removes the pass in reference from the list of weak
65
+ * references for the referent. This should be called from
66
+ * remove_weakref_fromt_referent as it will pass the required list
67
+ * argument.
66
68
*/
67
69
static void
68
70
remove_weakref (PyWeakReference * self , PyWeakReference * * list )
69
71
{
70
- if (* list == self )
72
+ if (* list == self ) {
71
73
/* If 'self' is the end of the list (and thus self->wr_next == NULL)
72
74
then the weakref list itself (and thus the value of *list) will
73
75
end up being set to NULL. */
74
76
* list = self -> wr_next ;
77
+ }
75
78
self -> wr_object = Py_None ;
76
- if (self -> wr_prev != NULL )
79
+ if (self -> wr_prev != NULL ) {
77
80
self -> wr_prev -> wr_next = self -> wr_next ;
78
- if (self -> wr_next != NULL )
81
+ }
82
+ if (self -> wr_next != NULL ) {
79
83
self -> wr_next -> wr_prev = self -> wr_prev ;
84
+ }
80
85
self -> wr_prev = NULL ;
81
86
self -> wr_next = NULL ;
82
87
}
0 commit comments