summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2001-10-07 03:54:51 (GMT)
committerTim Peters <tim.peters@gmail.com>2001-10-07 03:54:51 (GMT)
commitf2a67daca2206bab783abba99d428e5eaf36a8f7 (patch)
tree1e3360c426729cd72381d1308f8989cd9ce3cbae /Objects
parent0a1fc4e389b9839f2330083fb20e7a466835422f (diff)
downloadcpython-f2a67daca2206bab783abba99d428e5eaf36a8f7.zip
cpython-f2a67daca2206bab783abba99d428e5eaf36a8f7.tar.gz
cpython-f2a67daca2206bab783abba99d428e5eaf36a8f7.tar.bz2
Guido suggests, and I agree, to insist that SIZEOF_VOID_P be a power of 2.
This simplifies the rounding in _PyObject_VAR_SIZE, allows to restore the pre-rounding calling sequence, and allows some nice little simplifications in its callers. I'm still making it return a size_t, though.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/object.c8
-rw-r--r--Objects/typeobject.c4
2 files changed, 4 insertions, 8 deletions
diff --git a/Objects/object.c b/Objects/object.c
index 0237234..be8eb07 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -130,9 +130,7 @@ PyVarObject *
_PyObject_NewVar(PyTypeObject *tp, int nitems)
{
PyVarObject *op;
- size_t size;
-
- _PyObject_VAR_SIZE(size, tp, nitems);
+ const size_t size = _PyObject_VAR_SIZE(tp, nitems);
op = (PyVarObject *) PyObject_MALLOC(size);
if (op == NULL)
return (PyVarObject *)PyErr_NoMemory();
@@ -1158,8 +1156,8 @@ _PyObject_GetDictPtr(PyObject *obj)
if (dictoffset == 0)
return NULL;
if (dictoffset < 0) {
- size_t size;
- _PyObject_VAR_SIZE(size, tp, ((PyVarObject *)obj)->ob_size);
+ const size_t size = _PyObject_VAR_SIZE(tp,
+ ((PyVarObject *)obj)->ob_size);
dictoffset += (long)size;
assert(dictoffset > 0);
assert(dictoffset % SIZEOF_VOID_P == 0);
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 0342e71..0ec8175 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -191,9 +191,7 @@ PyObject *
PyType_GenericAlloc(PyTypeObject *type, int nitems)
{
PyObject *obj;
- size_t size;
-
- _PyObject_VAR_SIZE(size, type, nitems);
+ const size_t size = _PyObject_VAR_SIZE(type, nitems);
if (PyType_IS_GC(type))
obj = _PyObject_GC_Malloc(type, nitems);