Commit 5300b741 authored by Victor Stinner's avatar Victor Stinner

Use __Pyx_SET_SIZE() and __Pyx_SET_REFCNT()

Don't access directly PyObject.ob_refcnt and PyVarObject.ob_size.
parent 782a8733
...@@ -1191,7 +1191,7 @@ static void __Pyx_Coroutine_del(PyObject *self) { ...@@ -1191,7 +1191,7 @@ static void __Pyx_Coroutine_del(PyObject *self) {
#if !CYTHON_USE_TP_FINALIZE #if !CYTHON_USE_TP_FINALIZE
// Temporarily resurrect the object. // Temporarily resurrect the object.
assert(self->ob_refcnt == 0); assert(self->ob_refcnt == 0);
self->ob_refcnt = 1; __Pyx_SET_REFCNT(self, 1);
#endif #endif
__Pyx_PyThreadState_assign __Pyx_PyThreadState_assign
...@@ -1283,7 +1283,7 @@ static void __Pyx_Coroutine_del(PyObject *self) { ...@@ -1283,7 +1283,7 @@ static void __Pyx_Coroutine_del(PyObject *self) {
{ {
Py_ssize_t refcnt = self->ob_refcnt; Py_ssize_t refcnt = self->ob_refcnt;
_Py_NewReference(self); _Py_NewReference(self);
self->ob_refcnt = refcnt; __Pyx_SET_REFCNT(self, refcnt);
} }
#if CYTHON_COMPILING_IN_CPYTHON #if CYTHON_COMPILING_IN_CPYTHON
assert(PyType_IS_GC(self->ob_type) && assert(PyType_IS_GC(self->ob_type) &&
......
...@@ -88,7 +88,7 @@ static CYTHON_INLINE PyObject * newarrayobject(PyTypeObject *type, Py_ssize_t si ...@@ -88,7 +88,7 @@ static CYTHON_INLINE PyObject * newarrayobject(PyTypeObject *type, Py_ssize_t si
op->ob_descr = descr; op->ob_descr = descr;
op->allocated = size; op->allocated = size;
op->weakreflist = NULL; op->weakreflist = NULL;
op->ob_size = size; __Pyx_SET_SIZE(op, size);
if (size <= 0) { if (size <= 0) {
op->data.ob_item = NULL; op->data.ob_item = NULL;
} }
...@@ -116,7 +116,7 @@ static CYTHON_INLINE int resize(arrayobject *self, Py_ssize_t n) { ...@@ -116,7 +116,7 @@ static CYTHON_INLINE int resize(arrayobject *self, Py_ssize_t n) {
return -1; return -1;
} }
self->data.ob_item = (char*) items; self->data.ob_item = (char*) items;
self->ob_size = n; __Pyx_SET_SIZE(self, n);
self->allocated = n; self->allocated = n;
return 0; return 0;
} }
...@@ -126,7 +126,7 @@ static CYTHON_INLINE int resize_smart(arrayobject *self, Py_ssize_t n) { ...@@ -126,7 +126,7 @@ static CYTHON_INLINE int resize_smart(arrayobject *self, Py_ssize_t n) {
void *items = (void*) self->data.ob_item; void *items = (void*) self->data.ob_item;
Py_ssize_t newsize; Py_ssize_t newsize;
if (n < self->allocated && n*4 > self->allocated) { if (n < self->allocated && n*4 > self->allocated) {
self->ob_size = n; __Pyx_SET_SIZE(self, n);
return 0; return 0;
} }
newsize = n + (n / 2) + 1; newsize = n + (n / 2) + 1;
...@@ -140,7 +140,7 @@ static CYTHON_INLINE int resize_smart(arrayobject *self, Py_ssize_t n) { ...@@ -140,7 +140,7 @@ static CYTHON_INLINE int resize_smart(arrayobject *self, Py_ssize_t n) {
return -1; return -1;
} }
self->data.ob_item = (char*) items; self->data.ob_item = (char*) items;
self->ob_size = n; __Pyx_SET_SIZE(self, n);
self->allocated = newsize; self->allocated = newsize;
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment