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.)
This commit is contained in:
Guido van Rossum 2000-05-03 23:44:39 +00:00
parent 2808b744e8
commit b18618dab7
73 changed files with 658 additions and 407 deletions

View file

@ -124,7 +124,7 @@ _PyImport_Init()
++countD;
for (scan = _PyImport_StandardFiletab; scan->suffix != NULL; ++scan)
++countS;
filetab = malloc((countD + countS + 1) * sizeof(struct filedescr));
filetab = PyMem_NEW(struct filedescr, countD + countS + 1);
memcpy(filetab, _PyImport_DynLoadFiletab,
countD * sizeof(struct filedescr));
memcpy(filetab + countD, _PyImport_StandardFiletab,
@ -2398,10 +2398,10 @@ initimp()
}
/* API for embedding applications that want to add their own entries to the
table of built-in modules. This should normally be called *before*
Py_Initialize(). When the malloc() or realloc() call fails, -1 is returned
and the existing table is unchanged.
/* API for embedding applications that want to add their own entries
to the table of built-in modules. This should normally be called
*before* Py_Initialize(). When the table resize fails, -1 is
returned and the existing table is unchanged.
After a similar function by Just van Rossum. */
@ -2422,10 +2422,8 @@ PyImport_ExtendInittab(newtab)
;
/* Allocate new memory for the combined table */
if (our_copy == NULL)
p = malloc((i+n+1) * sizeof(struct _inittab));
else
p = realloc(our_copy, (i+n+1) * sizeof(struct _inittab));
p = our_copy;
PyMem_RESIZE(p, struct _inittab, i+n+1);
if (p == NULL)
return -1;