Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
17e7be60
Commit
17e7be60
authored
Aug 10, 2001
by
Neil Schemenauer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove "referents" structure (it's not needed). Check return value
of PyList_Append.
parent
a8b5f7d1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
20 deletions
+17
-20
Modules/gcmodule.c
Modules/gcmodule.c
+17
-20
No files found.
Modules/gcmodule.c
View file @
17e7be60
...
...
@@ -677,51 +677,48 @@ gc_get_thresh(PyObject *self, PyObject *args)
return
Py_BuildValue
(
"(iii)"
,
threshold0
,
threshold1
,
threshold2
);
}
struct
referents
{
PyObject
*
objs
;
int
seen
;
};
static
int
referentsvisit
(
PyObject
*
obj
,
struct
referents
*
ref
s
)
referentsvisit
(
PyObject
*
obj
,
PyObject
*
obj
s
)
{
if
(
PySequence_Contains
(
refs
->
objs
,
obj
))
{
refs
->
seen
=
1
;
if
(
PySequence_Contains
(
objs
,
obj
))
{
return
1
;
}
return
0
;
}
static
void
static
int
gc_referents_for
(
PyObject
*
objs
,
PyGC_Head
*
list
,
PyObject
*
resultlist
)
{
PyGC_Head
*
gc
;
PyObject
*
obj
;
traverseproc
traverse
;
struct
referents
refs
=
{
objs
,
0
};
for
(
gc
=
list
->
gc_next
;
gc
!=
list
;
gc
=
gc
->
gc_next
){
obj
=
PyObject_FROM_GC
(
gc
);
for
(
gc
=
list
->
gc_next
;
gc
!=
list
;
gc
=
gc
->
gc_next
)
{
obj
=
PyObject_FROM_GC
(
gc
);
traverse
=
obj
->
ob_type
->
tp_traverse
;
if
(
obj
==
objs
||
obj
==
resultlist
)
continue
;
if
(
traverse
(
obj
,
(
visitproc
)
referentsvisit
,
&
ref
s
))
{
PyList_Append
(
resultlist
,
obj
);
refs
.
seen
=
0
;
if
(
traverse
(
obj
,
(
visitproc
)
referentsvisit
,
obj
s
))
{
if
(
PyList_Append
(
resultlist
,
obj
)
<
0
)
return
0
;
/* error */
}
}
return
1
;
/* no error */
}
static
char
gc_get_referents__doc__
[]
=
"get_referents(*objs) -> list
\n
\
Return the list of objects that directly refer to any of objs."
;
static
PyObject
*
gc_get_referents
(
PyObject
*
self
,
PyObject
*
args
)
static
PyObject
*
gc_get_referents
(
PyObject
*
self
,
PyObject
*
args
)
{
PyObject
*
result
=
PyList_New
(
0
);
gc_referents_for
(
args
,
&
generation0
,
result
);
gc_referents_for
(
args
,
&
generation1
,
result
);
gc_referents_for
(
args
,
&
generation2
,
result
);
if
(
!
(
gc_referents_for
(
args
,
&
generation0
,
result
)
&&
gc_referents_for
(
args
,
&
generation1
,
result
)
&&
gc_referents_for
(
args
,
&
generation2
,
result
)))
{
Py_DECREF
(
result
);
return
NULL
;
}
return
result
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment