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
4e79f396
Commit
4e79f396
authored
Aug 29, 2001
by
Neil Schemenauer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use new GC API. Remove usage of BASICSIZE macros.
parent
b0976865
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
18 deletions
+18
-18
Objects/typeobject.c
Objects/typeobject.c
+18
-18
No files found.
Objects/typeobject.c
View file @
4e79f396
...
@@ -167,19 +167,19 @@ PyObject *
...
@@ -167,19 +167,19 @@ PyObject *
PyType_GenericAlloc
(
PyTypeObject
*
type
,
int
nitems
)
PyType_GenericAlloc
(
PyTypeObject
*
type
,
int
nitems
)
{
{
int
size
;
int
size
;
void
*
mem
;
PyObject
*
obj
;
PyObject
*
obj
;
/* Inline PyObject_New() so we can zero the memory */
/* Inline PyObject_New() so we can zero the memory */
size
=
_PyObject_VAR_SIZE
(
type
,
nitems
);
size
=
_PyObject_VAR_SIZE
(
type
,
nitems
);
mem
=
PyObject_MALLOC
(
size
);
if
(
PyType_IS_GC
(
type
))
{
if
(
mem
==
NULL
)
obj
=
_PyObject_GC_Malloc
(
type
,
nitems
);
}
else
{
obj
=
PyObject_MALLOC
(
size
);
}
if
(
obj
==
NULL
)
return
PyErr_NoMemory
();
return
PyErr_NoMemory
();
memset
(
mem
,
'\0'
,
size
);
memset
(
obj
,
'\0'
,
size
);
if
(
PyType_IS_GC
(
type
))
obj
=
PyObject_FROM_GC
(
mem
);
else
obj
=
(
PyObject
*
)
mem
;
if
(
type
->
tp_flags
&
Py_TPFLAGS_HEAPTYPE
)
if
(
type
->
tp_flags
&
Py_TPFLAGS_HEAPTYPE
)
Py_INCREF
(
type
);
Py_INCREF
(
type
);
if
(
type
->
tp_itemsize
==
0
)
if
(
type
->
tp_itemsize
==
0
)
...
@@ -187,7 +187,7 @@ PyType_GenericAlloc(PyTypeObject *type, int nitems)
...
@@ -187,7 +187,7 @@ PyType_GenericAlloc(PyTypeObject *type, int nitems)
else
else
(
void
)
PyObject_INIT_VAR
((
PyVarObject
*
)
obj
,
type
,
nitems
);
(
void
)
PyObject_INIT_VAR
((
PyVarObject
*
)
obj
,
type
,
nitems
);
if
(
PyType_IS_GC
(
type
))
if
(
PyType_IS_GC
(
type
))
PyObject_GC_Init
(
obj
);
_PyObject_GC_TRACK
(
obj
);
return
obj
;
return
obj
;
}
}
...
@@ -542,8 +542,8 @@ best_base(PyObject *bases)
...
@@ -542,8 +542,8 @@ best_base(PyObject *bases)
static
int
static
int
extra_ivars
(
PyTypeObject
*
type
,
PyTypeObject
*
base
)
extra_ivars
(
PyTypeObject
*
type
,
PyTypeObject
*
base
)
{
{
size_t
t_size
=
PyType_BASICSIZE
(
type
)
;
size_t
t_size
=
type
->
tp_basicsize
;
size_t
b_size
=
PyType_BASICSIZE
(
base
)
;
size_t
b_size
=
base
->
tp_basicsize
;
assert
(
t_size
>=
b_size
);
/* Else type smaller than base! */
assert
(
t_size
>=
b_size
);
/* Else type smaller than base! */
if
(
type
->
tp_itemsize
||
base
->
tp_itemsize
)
{
if
(
type
->
tp_itemsize
||
base
->
tp_itemsize
)
{
...
@@ -806,7 +806,7 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds)
...
@@ -806,7 +806,7 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds)
/* Add descriptors for custom slots from __slots__, or for __dict__ */
/* Add descriptors for custom slots from __slots__, or for __dict__ */
mp
=
et
->
members
;
mp
=
et
->
members
;
slotoffset
=
PyType_BASICSIZE
(
base
)
;
slotoffset
=
base
->
tp_basicsize
;
if
(
slots
!=
NULL
)
{
if
(
slots
!=
NULL
)
{
for
(
i
=
0
;
i
<
nslots
;
i
++
,
mp
++
)
{
for
(
i
=
0
;
i
<
nslots
;
i
++
,
mp
++
)
{
mp
->
name
=
PyString_AS_STRING
(
mp
->
name
=
PyString_AS_STRING
(
...
@@ -1241,13 +1241,13 @@ inherit_special(PyTypeObject *type, PyTypeObject *base)
...
@@ -1241,13 +1241,13 @@ inherit_special(PyTypeObject *type, PyTypeObject *base)
}
}
/* Copying basicsize is connected to the GC flags */
/* Copying basicsize is connected to the GC flags */
oldsize
=
PyType_BASICSIZE
(
base
)
;
oldsize
=
base
->
tp_basicsize
;
newsize
=
type
->
tp_basicsize
?
PyType_BASICSIZE
(
type
)
:
oldsize
;
newsize
=
type
->
tp_basicsize
?
type
->
tp_basicsize
:
oldsize
;
if
(
!
(
type
->
tp_flags
&
Py_TPFLAGS_GC
)
&&
if
(
!
(
type
->
tp_flags
&
Py_TPFLAGS_
HAVE_
GC
)
&&
(
base
->
tp_flags
&
Py_TPFLAGS_GC
)
&&
(
base
->
tp_flags
&
Py_TPFLAGS_
HAVE_
GC
)
&&
(
type
->
tp_flags
&
Py_TPFLAGS_HAVE_RICHCOMPARE
/*GC slots exist*/
)
&&
(
type
->
tp_flags
&
Py_TPFLAGS_HAVE_RICHCOMPARE
/*GC slots exist*/
)
&&
(
!
type
->
tp_traverse
&&
!
type
->
tp_clear
))
{
(
!
type
->
tp_traverse
&&
!
type
->
tp_clear
))
{
type
->
tp_flags
|=
Py_TPFLAGS_GC
;
type
->
tp_flags
|=
Py_TPFLAGS_
HAVE_
GC
;
if
(
type
->
tp_traverse
==
NULL
)
if
(
type
->
tp_traverse
==
NULL
)
type
->
tp_traverse
=
base
->
tp_traverse
;
type
->
tp_traverse
=
base
->
tp_traverse
;
if
(
type
->
tp_clear
==
NULL
)
if
(
type
->
tp_clear
==
NULL
)
...
@@ -1260,7 +1260,7 @@ inherit_special(PyTypeObject *type, PyTypeObject *base)
...
@@ -1260,7 +1260,7 @@ inherit_special(PyTypeObject *type, PyTypeObject *base)
type
->
tp_new
=
base
->
tp_new
;
type
->
tp_new
=
base
->
tp_new
;
}
}
}
}
PyType_SET_BASICSIZE
(
type
,
newsize
)
;
type
->
tp_basicsize
=
newsize
;
/* Copy other non-function slots */
/* Copy other non-function slots */
...
...
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