summaryrefslogtreecommitdiffstats
path: root/Modules/gcmodule.c
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 /Modules/gcmodule.c
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 'Modules/gcmodule.c')
-rw-r--r--Modules/gcmodule.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/Modules/gcmodule.c b/Modules/gcmodule.c
index 63a2370..34503e4 100644
--- a/Modules/gcmodule.c
+++ b/Modules/gcmodule.c
@@ -801,14 +801,10 @@ PyObject *
_PyObject_GC_Malloc(PyTypeObject *tp, int nitems)
{
PyObject *op;
- size_t basicsize;
+ const size_t basicsize = _PyObject_VAR_SIZE(tp, nitems);
#ifdef WITH_CYCLE_GC
- size_t nbytes;
- PyGC_Head *g;
-
- _PyObject_VAR_SIZE(basicsize, tp, nitems);
- nbytes = sizeof(PyGC_Head) + basicsize;
- g = PyObject_MALLOC(nbytes);
+ const size_t nbytes = sizeof(PyGC_Head) + basicsize;
+ PyGC_Head *g = PyObject_MALLOC(nbytes);
if (g == NULL)
return (PyObject *)PyErr_NoMemory();
g->gc_next = NULL;
@@ -824,7 +820,6 @@ _PyObject_GC_Malloc(PyTypeObject *tp, int nitems)
}
op = FROM_GC(g);
#else
- _PyObject_VAR_SIZE(basicsize, tp, nitems);
op = PyObject_MALLOC(basicsize);
if (op == NULL)
return (PyObject *)PyErr_NoMemory();
@@ -850,17 +845,14 @@ _PyObject_GC_NewVar(PyTypeObject *tp, int nitems)
PyVarObject *
_PyObject_GC_Resize(PyVarObject *op, int nitems)
{
- size_t basicsize;
+ const size_t basicsize = _PyObject_VAR_SIZE(op->ob_type, nitems);
#ifdef WITH_CYCLE_GC
PyGC_Head *g = AS_GC(op);
-
- _PyObject_VAR_SIZE(basicsize, op->ob_type, nitems);
g = PyObject_REALLOC(g, sizeof(PyGC_Head) + basicsize);
if (g == NULL)
return (PyVarObject *)PyErr_NoMemory();
op = (PyVarObject *) FROM_GC(g);
#else
- _PyObject_VAR_SIZE(basicsize, op->ob_type, nitems);
op = PyObject_REALLOC(op, basicsize);
if (op == NULL)
return (PyVarObject *)PyErr_NoMemory();