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
3b609241
Commit
3b609241
authored
Nov 23, 2011
by
Mark Florisson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not deallocate cython.array buffer if user-allocated
parent
e71755fd
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
4 deletions
+7
-4
Cython/Utility/MemoryView.pyx
Cython/Utility/MemoryView.pyx
+4
-2
tests/run/cythonarrayutil.pxi
tests/run/cythonarrayutil.pxi
+2
-1
tests/run/numpy_memoryview.pyx
tests/run/numpy_memoryview.pyx
+1
-1
No files found.
Cython/Utility/MemoryView.pyx
View file @
3b609241
...
@@ -33,8 +33,9 @@ cdef class array:
...
@@ -33,8 +33,9 @@ cdef class array:
Py_ssize_t
itemsize
Py_ssize_t
itemsize
unicode
mode
unicode
mode
bytes
_format
bytes
_format
void
(
*
callback_free_data
)(
char
*
data
)
void
(
*
callback_free_data
)(
void
*
data
)
# cdef object _memview
# cdef object _memview
cdef
bint
free_data
def
__cinit__
(
array
self
,
tuple
shape
,
Py_ssize_t
itemsize
,
format
,
def
__cinit__
(
array
self
,
tuple
shape
,
Py_ssize_t
itemsize
,
format
,
mode
=
u"c"
,
bint
allocate_buffer
=
True
):
mode
=
u"c"
,
bint
allocate_buffer
=
True
):
...
@@ -95,6 +96,7 @@ cdef class array:
...
@@ -95,6 +96,7 @@ cdef class array:
mode
=
decode
(
'ASCII'
)
mode
=
decode
(
'ASCII'
)
self
.
mode
=
mode
self
.
mode
=
mode
self
.
free_data
=
allocate_buffer
if
allocate_buffer
:
if
allocate_buffer
:
self
.
data
=
<
char
*>
malloc
(
self
.
len
)
self
.
data
=
<
char
*>
malloc
(
self
.
len
)
if
not
self
.
data
:
if
not
self
.
data
:
...
@@ -127,7 +129,7 @@ cdef class array:
...
@@ -127,7 +129,7 @@ cdef class array:
def
__dealloc__
(
array
self
):
def
__dealloc__
(
array
self
):
if
self
.
callback_free_data
!=
NULL
:
if
self
.
callback_free_data
!=
NULL
:
self
.
callback_free_data
(
self
.
data
)
self
.
callback_free_data
(
self
.
data
)
el
se
:
el
if
self
.
free_data
:
free
(
self
.
data
)
free
(
self
.
data
)
self
.
data
=
NULL
self
.
data
=
NULL
...
...
tests/run/cythonarrayutil.pxi
View file @
3b609241
from
libc.stdlib
cimport
malloc
,
free
from
libc.stdlib
cimport
malloc
,
free
cimport
cython
cimport
cython
cdef
void
callback
(
char
*
data
):
cdef
void
callback
(
void
*
data
):
print
"callback called"
print
"callback called"
free
(
data
)
def
create_array
(
shape
,
mode
,
use_callback
=
False
):
def
create_array
(
shape
,
mode
,
use_callback
=
False
):
cdef
cython
.
array
result
=
cython
.
array
(
shape
,
itemsize
=
sizeof
(
int
),
cdef
cython
.
array
result
=
cython
.
array
(
shape
,
itemsize
=
sizeof
(
int
),
...
...
tests/run/numpy_memoryview.pyx
View file @
3b609241
...
@@ -215,7 +215,7 @@ cdef extern from "bufaccess.h":
...
@@ -215,7 +215,7 @@ cdef extern from "bufaccess.h":
ctypedef
unsigned
int
td_h_ushort
# Defined as unsigned short
ctypedef
unsigned
int
td_h_ushort
# Defined as unsigned short
ctypedef
td_h_short
td_h_cy_short
ctypedef
td_h_short
td_h_cy_short
cdef
void
dealloc_callback
(
char
*
data
):
cdef
void
dealloc_callback
(
void
*
data
):
print
"deallocating..."
print
"deallocating..."
def
index
(
cython
.
array
array
):
def
index
(
cython
.
array
array
):
...
...
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