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
0e5f771f
Commit
0e5f771f
authored
Dec 30, 2018
by
Sergey Fedoseev
Committed by
Pablo Galindo
Dec 29, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-33234: Simplify list_preallocate_exact() (GH-11220)
parent
d51324a2
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
14 deletions
+3
-14
Objects/listobject.c
Objects/listobject.c
+3
-14
No files found.
Objects/listobject.c
View file @
0e5f771f
...
@@ -81,26 +81,15 @@ static int
...
@@ -81,26 +81,15 @@ static int
list_preallocate_exact
(
PyListObject
*
self
,
Py_ssize_t
size
)
list_preallocate_exact
(
PyListObject
*
self
,
Py_ssize_t
size
)
{
{
assert
(
self
->
ob_item
==
NULL
);
assert
(
self
->
ob_item
==
NULL
);
assert
(
size
>
0
);
PyObject
**
items
;
PyObject
**
items
=
PyMem_New
(
PyObject
*
,
size
);
size_t
allocated
;
allocated
=
(
size_t
)
size
;
if
(
allocated
>
(
size_t
)
PY_SSIZE_T_MAX
/
sizeof
(
PyObject
*
))
{
PyErr_NoMemory
();
return
-
1
;
}
if
(
size
==
0
)
{
allocated
=
0
;
}
items
=
(
PyObject
**
)
PyMem_New
(
PyObject
*
,
allocated
);
if
(
items
==
NULL
)
{
if
(
items
==
NULL
)
{
PyErr_NoMemory
();
PyErr_NoMemory
();
return
-
1
;
return
-
1
;
}
}
self
->
ob_item
=
items
;
self
->
ob_item
=
items
;
self
->
allocated
=
allocated
;
self
->
allocated
=
size
;
return
0
;
return
0
;
}
}
...
...
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