1
+ /*
2
+ Copyright (c) 2019, PyData Development Team
3
+ All rights reserved.
4
+
5
+ Distributed under the terms of the BSD Simplified License.
6
+
7
+ The full license is in the LICENSE file, distributed with this software.
8
+ */
9
+
1
10
#include <Python.h>
2
11
3
12
#define COMPILING_IN_PY2 (PY_VERSION_HEX <= 0x03000000)
@@ -31,15 +40,13 @@ typedef struct {
31
40
static PyTypeObject stolenbuf_type ; /* forward declare type */
32
41
33
42
static void
34
- stolenbuf_dealloc (stolenbufobject * self )
35
- {
43
+ stolenbuf_dealloc (stolenbufobject * self ) {
36
44
Py_DECREF (self -> invalid_bytes );
37
45
PyObject_Del (self );
38
46
}
39
47
40
48
static int
41
- stolenbuf_getbuffer (stolenbufobject * self , Py_buffer * view , int flags )
42
- {
49
+ stolenbuf_getbuffer (stolenbufobject * self , Py_buffer * view , int flags ) {
43
50
return PyBuffer_FillInfo (view ,
44
51
(PyObject * ) self ,
45
52
(void * ) PyString_AS_STRING (self -> invalid_bytes ),
@@ -51,8 +58,8 @@ stolenbuf_getbuffer(stolenbufobject *self, Py_buffer *view, int flags)
51
58
#if COMPILING_IN_PY2
52
59
53
60
static Py_ssize_t
54
- stolenbuf_getreadwritebuf (stolenbufobject * self , Py_ssize_t segment , void * * out )
55
- {
61
+ stolenbuf_getreadwritebuf (stolenbufobject * self ,
62
+ Py_ssize_t segment , void * * out ) {
56
63
if (segment != 0 ) {
57
64
PyErr_SetString (PyExc_SystemError ,
58
65
"accessing non-existent string segment" );
@@ -63,8 +70,7 @@ stolenbuf_getreadwritebuf(stolenbufobject *self, Py_ssize_t segment, void **out)
63
70
}
64
71
65
72
static Py_ssize_t
66
- stolenbuf_getsegcount (stolenbufobject * self , Py_ssize_t * len )
67
- {
73
+ stolenbuf_getsegcount (stolenbufobject * self , Py_ssize_t * len ) {
68
74
if (len ) {
69
75
* len = PyString_GET_SIZE (self -> invalid_bytes );
70
76
}
@@ -157,8 +163,7 @@ PyDoc_STRVAR(
157
163
however, if called through *unpacking like ``stolenbuf(*(a,))`` it would
158
164
only have the one reference (the tuple). */
159
165
static PyObject *
160
- move_into_mutable_buffer (PyObject * self , PyObject * bytes_rvalue )
161
- {
166
+ move_into_mutable_buffer (PyObject * self , PyObject * bytes_rvalue ) {
162
167
stolenbufobject * ret ;
163
168
164
169
if (!PyString_CheckExact (bytes_rvalue )) {
0 commit comments