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
a2671fa2
Commit
a2671fa2
authored
6 years ago
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement test for new PyMem_RawMalloc() functions.
parent
3040f4c3
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
0 deletions
+49
-0
tests/run/cpython_capi.pyx
tests/run/cpython_capi.pyx
+49
-0
No files found.
tests/run/cpython_capi.pyx
0 → 100644
View file @
a2671fa2
# mode: run
# tag: c-api
from
cpython
cimport
mem
def
test_pymalloc
():
"""
>>> test_pymalloc()
3
"""
cdef
char
*
m2
cdef
char
*
m
=
<
char
*>
mem
.
PyMem_Malloc
(
20
)
assert
m
try
:
m
[
0
]
=
1
m
[
1
]
=
2
m
[
2
]
=
3
m2
=
<
char
*>
mem
.
PyMem_Realloc
(
m
,
10
)
assert
m2
m
=
m2
return
m
[
2
]
finally
:
mem
.
PyMem_Free
(
m
)
def
test_pymalloc_raw
():
"""
>>> test_pymalloc_raw()
3
"""
cdef
char
*
m
cdef
char
*
m2
=
NULL
with
nogil
:
m
=
<
char
*>
mem
.
PyMem_RawMalloc
(
20
)
if
not
m
:
raise
MemoryError
()
try
:
m
[
0
]
=
1
m
[
1
]
=
2
m
[
2
]
=
3
m2
=
<
char
*>
mem
.
PyMem_RawRealloc
(
m
,
10
)
if
m2
:
m
=
m2
retval
=
m
[
2
]
finally
:
mem
.
PyMem_RawFree
(
m
)
assert
m2
return
retval
This diff is collapsed.
Click to expand it.
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