diff options
| author | Guido van Rossum <guido@python.org> | 2000-05-03 23:44:39 (GMT) |
|---|---|---|
| committer | Guido van Rossum <guido@python.org> | 2000-05-03 23:44:39 (GMT) |
| commit | b18618dab7b6b85bb05b084693706e59211fa180 (patch) | |
| tree | 785d51f6677da8366be2ad4b4296a62f53161276 /Objects/intobject.c | |
| parent | 2808b744e8d94459f189e1d89c97072d6a1f53b6 (diff) | |
| download | cpython-b18618dab7b6b85bb05b084693706e59211fa180.zip cpython-b18618dab7b6b85bb05b084693706e59211fa180.tar.gz cpython-b18618dab7b6b85bb05b084693706e59211fa180.tar.bz2 | |
Vladimir Marangozov's long-awaited malloc restructuring.
For more comments, read the patches@python.org archives.
For documentation read the comments in mymalloc.h and objimpl.h.
(This is not exactly what Vladimir posted to the patches list; I've
made a few changes, and Vladimir sent me a fix in private email for a
problem that only occurs in debug mode. I'm also holding back on his
change to main.c, which seems unnecessary to me.)
Diffstat (limited to 'Objects/intobject.c')
| -rw-r--r-- | Objects/intobject.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/Objects/intobject.c b/Objects/intobject.c index 0c8eefc..79435a9 100644 --- a/Objects/intobject.c +++ b/Objects/intobject.c @@ -94,9 +94,6 @@ err_ovf(msg) #define BHEAD_SIZE 8 /* Enough for a 64-bit pointer */ #define N_INTOBJECTS ((BLOCK_SIZE - BHEAD_SIZE) / sizeof(PyIntObject)) -#define PyMem_MALLOC malloc -#define PyMem_FREE free - struct _intblock { struct _intblock *next; PyIntObject objects[N_INTOBJECTS]; @@ -111,9 +108,10 @@ static PyIntObject * fill_free_list() { PyIntObject *p, *q; - p = (PyIntObject *)PyMem_MALLOC(sizeof(PyIntBlock)); + /* XXX Int blocks escape the object heap. Use PyObject_MALLOC ??? */ + p = (PyIntObject *) PyMem_MALLOC(sizeof(PyIntBlock)); if (p == NULL) - return (PyIntObject *)PyErr_NoMemory(); + return (PyIntObject *) PyErr_NoMemory(); ((PyIntBlock *)p)->next = block_list; block_list = (PyIntBlock *)p; p = &((PyIntBlock *)p)->objects[0]; @@ -164,11 +162,11 @@ PyInt_FromLong(ival) if ((free_list = fill_free_list()) == NULL) return NULL; } + /* PyObject_New is inlined */ v = free_list; free_list = (PyIntObject *)v->ob_type; - v->ob_type = &PyInt_Type; + PyObject_INIT(v, &PyInt_Type); v->ob_ival = ival; - _Py_NewReference((PyObject *)v); #if NSMALLNEGINTS + NSMALLPOSINTS > 0 if (-NSMALLNEGINTS <= ival && ival < NSMALLPOSINTS) { /* save this one for a following allocation */ @@ -933,7 +931,7 @@ PyInt_Fini() } } else { - PyMem_FREE(list); + PyMem_FREE(list); /* XXX PyObject_FREE ??? */ bf++; } isum += irem; |
