diff options
author | David Hewitt <1939362+davidhewitt@users.noreply.github.com> | 2021-12-22 13:07:46 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-22 13:07:46 (GMT) |
commit | 31ff96712e8f89ac1056c2da880b44650002219f (patch) | |
tree | f6cbc0c62bb78c3251a2ff7364fba22b6b36007a /Objects | |
parent | fc54e722a2e66971f1a8e16cff24c844bf9c5ac4 (diff) | |
download | cpython-31ff96712e8f89ac1056c2da880b44650002219f.zip cpython-31ff96712e8f89ac1056c2da880b44650002219f.tar.gz cpython-31ff96712e8f89ac1056c2da880b44650002219f.tar.bz2 |
bpo-46140: take more Py_buffer arguments as const * (GH-30217)
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/abstract.c | 7 | ||||
-rw-r--r-- | Objects/memoryobject.c | 18 |
2 files changed, 13 insertions, 12 deletions
diff --git a/Objects/abstract.c b/Objects/abstract.c index 5c533bf..6a2d5ed 100644 --- a/Objects/abstract.c +++ b/Objects/abstract.c @@ -474,7 +474,7 @@ PyBuffer_IsContiguous(const Py_buffer *view, char order) void* -PyBuffer_GetPointer(Py_buffer *view, Py_ssize_t *indices) +PyBuffer_GetPointer(const Py_buffer *view, const Py_ssize_t *indices) { char* pointer; int i; @@ -564,12 +564,13 @@ done: } int -PyBuffer_FromContiguous(Py_buffer *view, void *buf, Py_ssize_t len, char fort) +PyBuffer_FromContiguous(const Py_buffer *view, const void *buf, Py_ssize_t len, char fort) { int k; void (*addone)(int, Py_ssize_t *, const Py_ssize_t *); Py_ssize_t *indices, elements; - char *src, *ptr; + char *ptr; + const char *src; if (len > view->len) { len = view->len; diff --git a/Objects/memoryobject.c b/Objects/memoryobject.c index 6257455d..dfcb31e 100644 --- a/Objects/memoryobject.c +++ b/Objects/memoryobject.c @@ -389,7 +389,7 @@ copy_rec(const Py_ssize_t *shape, Py_ssize_t ndim, Py_ssize_t itemsize, /* Faster copying of one-dimensional arrays. */ static int -copy_single(Py_buffer *dest, Py_buffer *src) +copy_single(const Py_buffer *dest, const Py_buffer *src) { char *mem = NULL; @@ -421,7 +421,7 @@ copy_single(Py_buffer *dest, Py_buffer *src) structure. Copying is atomic, the function never fails with a partial copy. */ static int -copy_buffer(Py_buffer *dest, Py_buffer *src) +copy_buffer(const Py_buffer *dest, const Py_buffer *src) { char *mem = NULL; @@ -479,7 +479,7 @@ init_fortran_strides_from_shape(Py_buffer *view) or 'A' (Any). Assumptions: src has PyBUF_FULL information, src->ndim >= 1, len(mem) == src->len. */ static int -buffer_to_contiguous(char *mem, Py_buffer *src, char order) +buffer_to_contiguous(char *mem, const Py_buffer *src, char order) { Py_buffer dest; Py_ssize_t *strides; @@ -755,7 +755,7 @@ PyMemoryView_FromMemory(char *mem, Py_ssize_t size, int flags) without full information. Because of this fact init_shape_strides() must be able to reconstruct missing values. */ PyObject * -PyMemoryView_FromBuffer(Py_buffer *info) +PyMemoryView_FromBuffer(const Py_buffer *info) { _PyManagedBufferObject *mbuf; PyObject *mv; @@ -840,7 +840,7 @@ mbuf_copy_format(_PyManagedBufferObject *mbuf, const char *fmt) passes the altered format pointer to PyBuffer_Release(). */ static PyObject * -memory_from_contiguous_copy(Py_buffer *src, char order) +memory_from_contiguous_copy(const Py_buffer *src, char order) { _PyManagedBufferObject *mbuf; PyMemoryViewObject *mv; @@ -982,7 +982,7 @@ typedef struct { } Py_buffer_full; int -PyBuffer_ToContiguous(void *buf, Py_buffer *src, Py_ssize_t len, char order) +PyBuffer_ToContiguous(void *buf, const Py_buffer *src, Py_ssize_t len, char order) { Py_buffer_full *fb = NULL; int ret; @@ -2271,7 +2271,7 @@ memory_repr(PyMemoryViewObject *self) /**************************************************************************/ static char * -lookup_dimension(Py_buffer *view, char *ptr, int dim, Py_ssize_t index) +lookup_dimension(const Py_buffer *view, char *ptr, int dim, Py_ssize_t index) { Py_ssize_t nitems; /* items in the given dimension */ @@ -2297,7 +2297,7 @@ lookup_dimension(Py_buffer *view, char *ptr, int dim, Py_ssize_t index) /* Get the pointer to the item at index. */ static char * -ptr_from_index(Py_buffer *view, Py_ssize_t index) +ptr_from_index(const Py_buffer *view, Py_ssize_t index) { char *ptr = (char *)view->buf; return lookup_dimension(view, ptr, 0, index); @@ -2305,7 +2305,7 @@ ptr_from_index(Py_buffer *view, Py_ssize_t index) /* Get the pointer to the item at tuple. */ static char * -ptr_from_tuple(Py_buffer *view, PyObject *tup) +ptr_from_tuple(const Py_buffer *view, PyObject *tup) { char *ptr = (char *)view->buf; Py_ssize_t dim, nindices = PyTuple_GET_SIZE(tup); |