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
4cc6ac7b
Commit
4cc6ac7b
authored
Jul 01, 2000
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Neil Schemenauer: small fixes for GC
parent
ce8e1dc3
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
17 additions
and
13 deletions
+17
-13
Include/objimpl.h
Include/objimpl.h
+3
-6
Objects/classobject.c
Objects/classobject.c
+4
-0
Objects/dictobject.c
Objects/dictobject.c
+1
-0
Objects/funcobject.c
Objects/funcobject.c
+1
-0
Objects/listobject.c
Objects/listobject.c
+1
-0
Objects/object.c
Objects/object.c
+4
-7
Objects/tupleobject.c
Objects/tupleobject.c
+3
-0
No files found.
Include/objimpl.h
View file @
4cc6ac7b
...
@@ -183,6 +183,8 @@ extern DL_IMPORT(void) _PyObject_Del Py_PROTO((PyObject *));
...
@@ -183,6 +183,8 @@ extern DL_IMPORT(void) _PyObject_Del Py_PROTO((PyObject *));
(PyVarObject *) PyObject_MALLOC( _PyObject_VAR_SIZE((typeobj),(n)) ),\
(PyVarObject *) PyObject_MALLOC( _PyObject_VAR_SIZE((typeobj),(n)) ),\
(typeobj), (n)) )
(typeobj), (n)) )
#define PyObject_DEL(op) PyObject_FREE(op)
/* This example code implements an object constructor with a custom
/* This example code implements an object constructor with a custom
allocator, where PyObject_New is inlined, and shows the important
allocator, where PyObject_New is inlined, and shows the important
distinction between two steps (at least):
distinction between two steps (at least):
...
@@ -221,7 +223,7 @@ extern DL_IMPORT(void) _PyObject_Del Py_PROTO((PyObject *));
...
@@ -221,7 +223,7 @@ extern DL_IMPORT(void) _PyObject_Del Py_PROTO((PyObject *));
PyObject_{New, VarNew, Del} to manage the memory. Set the type flag
PyObject_{New, VarNew, Del} to manage the memory. Set the type flag
Py_TPFLAGS_GC and define the type method tp_recurse. You should also
Py_TPFLAGS_GC and define the type method tp_recurse. You should also
add the method tp_clear if your object is mutable. Include
add the method tp_clear if your object is mutable. Include
PyGC_
INFO
_SIZE in the calculation of tp_basicsize. Call
PyGC_
HEAD
_SIZE in the calculation of tp_basicsize. Call
PyObject_GC_Init after the pointers followed by tp_recurse become
PyObject_GC_Init after the pointers followed by tp_recurse become
valid (usually just before returning the object from the allocation
valid (usually just before returning the object from the allocation
method. Call PyObject_GC_Fini before those pointers become invalid
method. Call PyObject_GC_Fini before those pointers become invalid
...
@@ -234,7 +236,6 @@ extern DL_IMPORT(void) _PyObject_Del Py_PROTO((PyObject *));
...
@@ -234,7 +236,6 @@ extern DL_IMPORT(void) _PyObject_Del Py_PROTO((PyObject *));
#define PyObject_GC_Fini(op)
#define PyObject_GC_Fini(op)
#define PyObject_AS_GC(op) (op)
#define PyObject_AS_GC(op) (op)
#define PyObject_FROM_GC(op) (op)
#define PyObject_FROM_GC(op) (op)
#define PyObject_DEL(op) PyObject_FREE(op)
#else
#else
...
@@ -268,10 +269,6 @@ typedef struct _gc_head {
...
@@ -268,10 +269,6 @@ typedef struct _gc_head {
/* Get the object given the PyGC_Head */
/* Get the object given the PyGC_Head */
#define PyObject_FROM_GC(g) ((PyObject *)(((PyGC_Head *)g)+1))
#define PyObject_FROM_GC(g) ((PyObject *)(((PyGC_Head *)g)+1))
#define PyObject_DEL(op) PyObject_FREE( PyObject_IS_GC(op) ? \
(ANY *)PyObject_AS_GC(op) : \
(ANY *)(op) )
#endif
/* WITH_CYCLE_GC */
#endif
/* WITH_CYCLE_GC */
#ifdef __cplusplus
#ifdef __cplusplus
...
...
Objects/classobject.c
View file @
4cc6ac7b
...
@@ -128,6 +128,7 @@ class_dealloc(op)
...
@@ -128,6 +128,7 @@ class_dealloc(op)
Py_XDECREF
(
op
->
cl_getattr
);
Py_XDECREF
(
op
->
cl_getattr
);
Py_XDECREF
(
op
->
cl_setattr
);
Py_XDECREF
(
op
->
cl_setattr
);
Py_XDECREF
(
op
->
cl_delattr
);
Py_XDECREF
(
op
->
cl_delattr
);
op
=
(
PyClassObject
*
)
PyObject_AS_GC
(
op
);
PyObject_DEL
(
op
);
PyObject_DEL
(
op
);
}
}
...
@@ -473,6 +474,7 @@ PyInstance_New(class, arg, kw)
...
@@ -473,6 +474,7 @@ PyInstance_New(class, arg, kw)
inst
->
in_dict
=
PyDict_New
();
inst
->
in_dict
=
PyDict_New
();
PyObject_GC_Init
(
inst
);
PyObject_GC_Init
(
inst
);
if
(
inst
->
in_dict
==
NULL
)
{
if
(
inst
->
in_dict
==
NULL
)
{
inst
=
(
PyInstanceObject
*
)
PyObject_AS_GC
(
inst
);
PyObject_DEL
(
inst
);
PyObject_DEL
(
inst
);
return
NULL
;
return
NULL
;
}
}
...
@@ -588,6 +590,7 @@ instance_dealloc(inst)
...
@@ -588,6 +590,7 @@ instance_dealloc(inst)
#endif
/* Py_TRACE_REFS */
#endif
/* Py_TRACE_REFS */
Py_DECREF
(
inst
->
in_class
);
Py_DECREF
(
inst
->
in_class
);
Py_XDECREF
(
inst
->
in_dict
);
Py_XDECREF
(
inst
->
in_dict
);
inst
=
(
PyInstanceObject
*
)
PyObject_AS_GC
(
inst
);
PyObject_DEL
(
inst
);
PyObject_DEL
(
inst
);
}
}
...
@@ -1763,6 +1766,7 @@ PyMethod_Fini()
...
@@ -1763,6 +1766,7 @@ PyMethod_Fini()
while
(
free_list
)
{
while
(
free_list
)
{
PyMethodObject
*
im
=
free_list
;
PyMethodObject
*
im
=
free_list
;
free_list
=
(
PyMethodObject
*
)(
im
->
im_self
);
free_list
=
(
PyMethodObject
*
)(
im
->
im_self
);
im
=
(
PyMethodObject
*
)
PyObject_AS_GC
(
im
);
PyObject_DEL
(
im
);
PyObject_DEL
(
im
);
}
}
}
}
Objects/dictobject.c
View file @
4cc6ac7b
...
@@ -472,6 +472,7 @@ dict_dealloc(mp)
...
@@ -472,6 +472,7 @@ dict_dealloc(mp)
}
}
if
(
mp
->
ma_table
!=
NULL
)
if
(
mp
->
ma_table
!=
NULL
)
PyMem_DEL
(
mp
->
ma_table
);
PyMem_DEL
(
mp
->
ma_table
);
mp
=
(
dictobject
*
)
PyObject_AS_GC
(
mp
);
PyObject_DEL
(
mp
);
PyObject_DEL
(
mp
);
Py_TRASHCAN_SAFE_END
(
mp
)
Py_TRASHCAN_SAFE_END
(
mp
)
}
}
...
...
Objects/funcobject.c
View file @
4cc6ac7b
...
@@ -172,6 +172,7 @@ func_dealloc(op)
...
@@ -172,6 +172,7 @@ func_dealloc(op)
Py_DECREF
(
op
->
func_name
);
Py_DECREF
(
op
->
func_name
);
Py_XDECREF
(
op
->
func_defaults
);
Py_XDECREF
(
op
->
func_defaults
);
Py_XDECREF
(
op
->
func_doc
);
Py_XDECREF
(
op
->
func_doc
);
op
=
(
PyFunctionObject
*
)
PyObject_AS_GC
(
op
);
PyObject_DEL
(
op
);
PyObject_DEL
(
op
);
}
}
...
...
Objects/listobject.c
View file @
4cc6ac7b
...
@@ -209,6 +209,7 @@ list_dealloc(op)
...
@@ -209,6 +209,7 @@ list_dealloc(op)
}
}
PyMem_FREE
(
op
->
ob_item
);
PyMem_FREE
(
op
->
ob_item
);
}
}
op
=
(
PyListObject
*
)
PyObject_AS_GC
(
op
);
PyObject_DEL
(
op
);
PyObject_DEL
(
op
);
Py_TRASHCAN_SAFE_END
(
op
)
Py_TRASHCAN_SAFE_END
(
op
)
}
}
...
...
Objects/object.c
View file @
4cc6ac7b
...
@@ -171,14 +171,11 @@ _PyObject_Del(op)
...
@@ -171,14 +171,11 @@ _PyObject_Del(op)
PyObject
*
op
;
PyObject
*
op
;
{
{
#ifdef WITH_CYCLE_GC
#ifdef WITH_CYCLE_GC
if
(
PyType_IS_GC
(
op
->
ob_type
))
{
if
(
op
&&
PyType_IS_GC
(
op
->
ob_type
))
{
PyGC_Head
*
g
=
PyObject_AS_GC
(
op
);
op
=
(
PyObject
*
)
PyObject_AS_GC
(
op
);
PyObject_FREE
(
g
);
}
else
#endif
{
PyObject_FREE
(
op
);
}
}
#endif
PyObject_FREE
(
op
);
}
}
#ifndef WITH_CYCLE_GC
#ifndef WITH_CYCLE_GC
...
...
Objects/tupleobject.c
View file @
4cc6ac7b
...
@@ -175,6 +175,7 @@ tupledealloc(op)
...
@@ -175,6 +175,7 @@ tupledealloc(op)
}
}
#endif
#endif
}
}
op
=
(
PyTupleObject
*
)
PyObject_AS_GC
(
op
);
PyObject_DEL
(
op
);
PyObject_DEL
(
op
);
done:
done:
Py_TRASHCAN_SAFE_END
(
op
)
Py_TRASHCAN_SAFE_END
(
op
)
...
@@ -559,6 +560,7 @@ _PyTuple_Resize(pv, newsize, last_is_sticky)
...
@@ -559,6 +560,7 @@ _PyTuple_Resize(pv, newsize, last_is_sticky)
*
pv
=
(
PyObject
*
)
sv
;
*
pv
=
(
PyObject
*
)
sv
;
if
(
sv
==
NULL
)
{
if
(
sv
==
NULL
)
{
PyObject_GC_Init
((
PyObject
*
)
v
);
PyObject_GC_Init
((
PyObject
*
)
v
);
v
=
(
PyTupleObject
*
)
PyObject_AS_GC
(
v
);
PyObject_DEL
(
v
);
PyObject_DEL
(
v
);
PyErr_NoMemory
();
PyErr_NoMemory
();
return
-
1
;
return
-
1
;
...
@@ -595,6 +597,7 @@ PyTuple_Fini()
...
@@ -595,6 +597,7 @@ PyTuple_Fini()
while
(
p
)
{
while
(
p
)
{
q
=
p
;
q
=
p
;
p
=
(
PyTupleObject
*
)(
p
->
ob_item
[
0
]);
p
=
(
PyTupleObject
*
)(
p
->
ob_item
[
0
]);
q
=
(
PyTupleObject
*
)
PyObject_AS_GC
(
q
);
PyObject_DEL
(
q
);
PyObject_DEL
(
q
);
}
}
}
}
...
...
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