Debian Codegraph @

Include/internal/pycore_c_array.h

raw
1 #ifndef Py_INTERNAL_C_ARRAY_H
2 #define Py_INTERNAL_C_ARRAY_H
3
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
7
8 #ifndef Py_BUILD_CORE
9 # error "this header requires Py_BUILD_CORE define"
10 #endif
11
12
13 /* Utility for a number of growing arrays */
14
15 typedef struct {
16 void *array; /* pointer to the array */
17 int allocated_entries; /* pointer to the capacity of the array */
18 size_t item_size; /* size of each element */
19 int initial_num_entries; /* initial allocation size */
20 } _Py_c_array_t;
21
22
23 int _Py_CArray_Init(_Py_c_array_t* array, int item_size, int initial_num_entries);
24 void _Py_CArray_Fini(_Py_c_array_t* array);
25
26 /* If idx is out of bounds:
27 * If arr->array is NULL, allocate arr->initial_num_entries slots.
28 * Otherwise, double its size.
29 *
30 * Return 0 if successful and -1 (with exception set) otherwise.
31 */
32 int _Py_CArray_EnsureCapacity(_Py_c_array_t *c_array, int idx);
33
34
35 #ifdef __cplusplus
36 }
37 #endif
38
39 #endif /* !Py_INTERNAL_C_ARRAY_H */