Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
2bcc2325
Commit
2bcc2325
authored
Jun 24, 2020
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Deallocate cypclass wrapper in cyobject destructor
parent
80fcedd4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
4 deletions
+13
-4
Cython/Compiler/CypclassWrapper.py
Cython/Compiler/CypclassWrapper.py
+3
-2
Cython/Utility/CyObjects.cpp
Cython/Utility/CyObjects.cpp
+10
-2
No files found.
Cython/Compiler/CypclassWrapper.py
View file @
2bcc2325
...
...
@@ -589,7 +589,6 @@ def generate_cyp_class_attrs_destructor_definition(entry, code):
code
.
putln
(
"Cy_XDECREF(this->%s);"
%
attr
.
cname
)
code
.
putln
(
"}"
)
def
generate_cyp_class_activate_function
(
entry
,
code
):
"""
Generate activate function for activable cypclass entries
...
...
@@ -1042,7 +1041,9 @@ def generate_cyp_class_wrapper_definition(type, wrapper_entry, constructor_entry
objstruct_cname
=
type
.
wrapper_type
.
objstruct_cname
cclass_wrapper_base
=
type
.
wrapped_base_type
().
wrapper_type
code
.
putln
(
"if(self) {"
)
code
.
putln
(
"%s * wrapper = new %s();"
%
(
objstruct_cname
,
objstruct_cname
))
code
.
putln
(
"printf(
\
"
allocating wrapper for %s cypclass
\
\
n
\
"
);"
%
type
.
name
)
code
.
putln
(
"%s * wrapper = (%s *) ::operator new(sizeof *wrapper);"
%
(
objstruct_cname
,
objstruct_cname
))
code
.
putln
(
"printf(
\
"
allocated wrapper object @ %p
\
\
n
\
\
n
\
"
, wrapper);"
)
code
.
putln
(
"((%s *)wrapper)->%s = self;"
%
(
cclass_wrapper_base
.
objstruct_cname
,
Naming
.
cypclass_attr_cname
))
code
.
putln
(
"PyObject * wrapper_as_py = (PyObject *) wrapper;"
)
code
.
putln
(
"wrapper_as_py->ob_refcnt = 0;"
)
...
...
Cython/Utility/CyObjects.cpp
View file @
2bcc2325
...
...
@@ -63,8 +63,8 @@
RecursiveUpgradeableRWLock
ob_lock
;
public:
PyObject
*
cy_pyobject
;
CyObject
()
:
nogil_ob_refcnt
(
1
)
{}
virtual
~
CyObject
()
{}
CyObject
()
:
nogil_ob_refcnt
(
1
)
,
cy_pyobject
(
NULL
)
{}
virtual
~
CyObject
()
;
void
CyObject_INCREF
();
int
CyObject_DECREF
();
void
CyObject_RLOCK
();
...
...
@@ -446,6 +446,14 @@ int RecursiveUpgradeableRWLock::trywlock() {
return
0
;
}
CyObject
::~
CyObject
()
{
if
(
cy_pyobject
)
{
printf
(
"deleting wrapper object @ %p
\n
"
,
cy_pyobject
);
printf
(
"python refcount: %ld
\n
"
,
cy_pyobject
->
ob_refcnt
);
::
operator
delete
(
cy_pyobject
);
printf
(
"wrapper deleted
\n\n
"
);
}
}
void
CyObject
::
CyObject_INCREF
()
{
...
...
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