/src/cpython-install/include/python3.15/cpython/bytearrayobject.h
Line | Count | Source (jump to first uncovered line) |
1 | | #ifndef Py_CPYTHON_BYTEARRAYOBJECT_H |
2 | | # error "this header file must not be included directly" |
3 | | #endif |
4 | | |
5 | | /* Object layout */ |
6 | | typedef struct { |
7 | | PyObject_VAR_HEAD |
8 | | Py_ssize_t ob_alloc; /* How many bytes allocated in ob_bytes */ |
9 | | char *ob_bytes; /* Physical backing buffer */ |
10 | | char *ob_start; /* Logical start inside ob_bytes */ |
11 | | Py_ssize_t ob_exports; /* How many buffer exports */ |
12 | | } PyByteArrayObject; |
13 | | |
14 | | PyAPI_DATA(char) _PyByteArray_empty_string[]; |
15 | | |
16 | | /* Macros and static inline functions, trading safety for speed */ |
17 | | #define _PyByteArray_CAST(op) \ |
18 | | (assert(PyByteArray_Check(op)), _Py_CAST(PyByteArrayObject*, op)) |
19 | | |
20 | | static inline char* PyByteArray_AS_STRING(PyObject *op) |
21 | 0 | { |
22 | 0 | PyByteArrayObject *self = _PyByteArray_CAST(op); |
23 | 0 | if (Py_SIZE(self)) { |
24 | 0 | return self->ob_start; |
25 | 0 | } |
26 | 0 | return _PyByteArray_empty_string; |
27 | 0 | } |
28 | | #define PyByteArray_AS_STRING(self) PyByteArray_AS_STRING(_PyObject_CAST(self)) |
29 | | |
30 | 0 | static inline Py_ssize_t PyByteArray_GET_SIZE(PyObject *op) { |
31 | 0 | PyByteArrayObject *self = _PyByteArray_CAST(op); |
32 | 0 | #ifdef Py_GIL_DISABLED |
33 | 0 | return _Py_atomic_load_ssize_relaxed(&(_PyVarObject_CAST(self)->ob_size)); |
34 | 0 | #else |
35 | 0 | return Py_SIZE(self); |
36 | 0 | #endif |
37 | 0 | } |
38 | | #define PyByteArray_GET_SIZE(self) PyByteArray_GET_SIZE(_PyObject_CAST(self)) |