mirror of
https://github.com/python/cpython.git
synced 2025-07-07 19:35:27 +00:00
gh-130080: move _Py_EnsureArrayLargeEnough to a separate header so it can be used outside of the compiler (#130930)
This commit is contained in:
parent
9a63138e09
commit
4242c2b8d0
5 changed files with 108 additions and 52 deletions
|
@ -1,5 +1,6 @@
|
|||
#include "Python.h"
|
||||
#include "opcode.h"
|
||||
#include "pycore_c_array.h" // _Py_CArray_EnsureCapacity
|
||||
#include "pycore_flowgraph.h"
|
||||
#include "pycore_compile.h"
|
||||
#include "pycore_intrinsics.h"
|
||||
|
@ -141,13 +142,16 @@ static int
|
|||
basicblock_next_instr(basicblock *b)
|
||||
{
|
||||
assert(b != NULL);
|
||||
RETURN_IF_ERROR(
|
||||
_PyCompile_EnsureArrayLargeEnough(
|
||||
b->b_iused + 1,
|
||||
(void**)&b->b_instr,
|
||||
&b->b_ialloc,
|
||||
DEFAULT_BLOCK_SIZE,
|
||||
sizeof(cfg_instr)));
|
||||
_Py_c_array_t array = {
|
||||
.array = (void*)b->b_instr,
|
||||
.allocated_entries = b->b_ialloc,
|
||||
.item_size = sizeof(cfg_instr),
|
||||
.initial_num_entries = DEFAULT_BLOCK_SIZE,
|
||||
};
|
||||
|
||||
RETURN_IF_ERROR(_Py_CArray_EnsureCapacity(&array, b->b_iused + 1));
|
||||
b->b_instr = array.array;
|
||||
b->b_ialloc = array.allocated_entries;
|
||||
return b->b_iused++;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue