[Patches] PyMem [7/8] - Objects/*

Vladimir Marangozov Vladimir.Marangozov@inrialpes.fr
Fri, 25 Feb 2000 13:33:04 +0100 (CET)


- General cleanup w.r.t various mallocs

- In object.c, added _PyObject_Del and nuked PyMem_{Malloc, Realloc, Free}
  (MS_COREDLL is still a mystery...)

-- 
       Vladimir MARANGOZOV          | Vladimir.Marangozov@inrialpes.fr
http://sirac.inrialpes.fr/~marangoz | tel:(+33-4)76615277 fax:76615252

--
I confirm that, to the best of my knowledge and belief, this contribution is
free of any claims of third parties under copyright, patent or other rights
or interests ("claims").  To the extent that I have any such claims, I
hereby grant to CNRI a nonexclusive, irrevocable, royalty-free, worldwide
license to reproduce, distribute, perform and/or display publicly, prepare
derivative versions, and otherwise use this contribution as part of the
Python software and its related documentation, or any derivative versions
thereof, at no cost to CNRI or its licensed users, and to authorize others
to do so.

I acknowledge that CNRI may, at its sole discretion, decide whether or not
to incorporate this contribution in the Python software and its related
documentation.  I further grant CNRI permission to use my name and other
identifying information provided to CNRI by me for use in connection with
the Python software and its related documentation.

-------------------------------[ cut here ]---------------------------  
diff -cr PyCVS/Objects/bufferobject.c PyMem/Objects/bufferobject.c
*** PyCVS/Objects/bufferobject.c	Thu Feb 24 14:49:47 2000
--- PyMem/Objects/bufferobject.c	Fri Feb 25 09:10:47 2000
***************
*** 32,38 ****
  /* Buffer object implementation */
  
  #include "Python.h"
! 
  
  typedef struct {
  	PyObject_HEAD
--- 32,38 ----
  /* Buffer object implementation */
  
  #include "Python.h"
! #include "pycore.h"
  
  typedef struct {
  	PyObject_HEAD
***************
*** 188,194 ****
  				"size must be zero or positive");
  		return NULL;
  	}
! 	b = (PyBufferObject *)malloc(sizeof(*b) + size);
  	if ( b == NULL )
  		return PyErr_NoMemory();
  	b->ob_type = &PyBuffer_Type;
--- 188,194 ----
  				"size must be zero or positive");
  		return NULL;
  	}
! 	b = (PyBufferObject *) PyMem_MALLOC(sizeof(*b) + size);
  	if ( b == NULL )
  		return PyErr_NoMemory();
  	b->ob_type = &PyBuffer_Type;
***************
*** 212,218 ****
  	PyBufferObject *self;
  {
  	Py_XDECREF(self->b_base);
! 	free((void *)self);
  }
  
  static int
--- 212,218 ----
  	PyBufferObject *self;
  {
  	Py_XDECREF(self->b_base);
! 	PyObject_DEL(self);
  }
  
  static int
diff -cr PyCVS/Objects/classobject.c PyMem/Objects/classobject.c
*** PyCVS/Objects/classobject.c	Thu Feb 24 14:49:47 2000
--- PyMem/Objects/classobject.c	Thu Feb 24 20:18:41 2000
***************
*** 32,37 ****
--- 32,39 ----
  /* Class object implementation */
  
  #include "Python.h"
+ #include "pycore.h"
+ 
  #include "structmember.h"
  
  /* Forward */
***************
*** 146,152 ****
  	Py_XDECREF(op->cl_getattr);
  	Py_XDECREF(op->cl_setattr);
  	Py_XDECREF(op->cl_delattr);
! 	free((ANY *)op);
  }
  
  static PyObject *
--- 148,154 ----
  	Py_XDECREF(op->cl_getattr);
  	Py_XDECREF(op->cl_setattr);
  	Py_XDECREF(op->cl_delattr);
! 	PyObject_DEL((ANY *)op);
  }
  
  static PyObject *
***************
*** 561,567 ****
  #endif /* Py_TRACE_REFS */
  	Py_DECREF(inst->in_class);
  	Py_XDECREF(inst->in_dict);
! 	free((ANY *)inst);
  }
  
  static PyObject *
--- 563,569 ----
  #endif /* Py_TRACE_REFS */
  	Py_DECREF(inst->in_class);
  	Py_XDECREF(inst->in_dict);
! 	PyObject_DEL(inst);
  }
  
  static PyObject *
***************
*** 1623,1630 ****
  PyMethod_Fini()
  {
  	while (free_list) {
! 		PyMethodObject *v = free_list;
! 		free_list = (PyMethodObject *)(v->im_self);
! 		PyMem_DEL(v);
  	}
  }
--- 1625,1632 ----
  PyMethod_Fini()
  {
  	while (free_list) {
! 		PyMethodObject *im = free_list;
! 		free_list = (PyMethodObject *)(im->im_self);
! 		PyObject_DEL(im);
  	}
  }
diff -cr PyCVS/Objects/cobject.c PyMem/Objects/cobject.c
*** PyCVS/Objects/cobject.c	Thu Feb 24 14:49:47 2000
--- PyMem/Objects/cobject.c	Thu Feb 24 23:49:18 2000
***************
*** 32,38 ****
  /* Wrap void* pointers to be passed between C modules */
  
  #include "Python.h"
! 
  
  /* Declarations for objects of type PyCObject */
  
--- 32,38 ----
  /* Wrap void* pointers to be passed between C modules */
  
  #include "Python.h"
! #include "pycore.h"
  
  /* Declarations for objects of type PyCObject */
  
***************
*** 151,157 ****
  	    else
  	          (self->destructor)(self->cobject);
  	  }
! 	PyMem_DEL(self);
  }
  
  
--- 151,157 ----
  	    else
  	          (self->destructor)(self->cobject);
  	  }
! 	PyObject_DEL(self);
  }
  
  
diff -cr PyCVS/Objects/complexobject.c PyMem/Objects/complexobject.c
*** PyCVS/Objects/complexobject.c	Thu Feb 24 14:49:47 2000
--- PyMem/Objects/complexobject.c	Fri Feb 25 09:07:02 2000
***************
*** 38,43 ****
--- 38,45 ----
  #ifndef WITHOUT_COMPLEX
  
  #include "Python.h"
+ #include "pycore.h"
+ 
  #include "mymath.h"
  
  #ifdef HAVE_LIMITS_H
***************
*** 167,173 ****
  	Py_complex cval;
  {
  	register PyComplexObject *op =
! 		(PyComplexObject *) malloc(sizeof(PyComplexObject));
  	if (op == NULL)
  		return PyErr_NoMemory();
  	op->ob_type = &PyComplex_Type;
--- 169,175 ----
  	Py_complex cval;
  {
  	register PyComplexObject *op =
! 		(PyComplexObject *) PyMem_MALLOC(sizeof(PyComplexObject));;
  	if (op == NULL)
  		return PyErr_NoMemory();
  	op->ob_type = &PyComplex_Type;
***************
*** 226,232 ****
  complex_dealloc(op)
  	PyObject *op;
  {
! 	PyMem_DEL(op);
  }
  
  
--- 228,234 ----
  complex_dealloc(op)
  	PyObject *op;
  {
! 	PyObject_DEL(op);
  }
  
  
diff -cr PyCVS/Objects/dictobject.c PyMem/Objects/dictobject.c
*** PyCVS/Objects/dictobject.c	Thu Feb 24 14:49:47 2000
--- PyMem/Objects/dictobject.c	Fri Feb 25 00:03:10 2000
***************
*** 32,38 ****
  /* Dictionary object implementation using a hash table */
  
  #include "Python.h"
! 
  
  /*
   * MINSIZE is the minimum size of a dictionary.
--- 32,38 ----
  /* Dictionary object implementation using a hash table */
  
  #include "Python.h"
! #include "pycore.h"
  
  /*
   * MINSIZE is the minimum size of a dictionary.
***************
*** 277,283 ****
  			break;
  		}
  	}
! 	newtable = (dictentry *) malloc(sizeof(dictentry) * newsize);
  	if (newtable == NULL) {
  		PyErr_NoMemory();
  		return -1;
--- 277,283 ----
  			break;
  		}
  	}
! 	newtable = PyMem_NEW(dictentry, newsize);
  	if (newtable == NULL) {
  		PyErr_NoMemory();
  		return -1;
***************
*** 301,307 ****
  		}
  	}
  
! 	PyMem_XDEL(oldtable);
  	return 0;
  }
  
--- 301,308 ----
  		}
  	}
  
! 	if (oldtable != NULL)
! 		PyMem_DEL(oldtable);
  	return 0;
  }
  
***************
*** 487,494 ****
  			Py_DECREF(ep->me_value);
  		}
  	}
! 	PyMem_XDEL(mp->ma_table);
! 	PyMem_DEL(mp);
  }
  
  static int
--- 488,496 ----
  			Py_DECREF(ep->me_value);
  		}
  	}
! 	if (mp->ma_table != NULL)
! 		PyMem_DEL(mp->ma_table);
! 	PyObject_DEL(mp);
  }
  
  static int
diff -cr PyCVS/Objects/fileobject.c PyMem/Objects/fileobject.c
*** PyCVS/Objects/fileobject.c	Thu Feb 24 14:49:47 2000
--- PyMem/Objects/fileobject.c	Fri Feb 25 00:06:33 2000
***************
*** 32,37 ****
--- 32,39 ----
  /* File object implementation */
  
  #include "Python.h"
+ #include "pycore.h"
+ 
  #include "structmember.h"
  
  #ifndef DONT_HAVE_SYS_TYPES_H
***************
*** 209,215 ****
  	if (f->f_mode != NULL) {
  		Py_DECREF(f->f_mode);
  	}
! 	free((char *)f);
  }
  
  static PyObject *
--- 211,217 ----
  	if (f->f_mode != NULL) {
  		Py_DECREF(f->f_mode);
  	}
! 	PyObject_DEL(f);
  }
  
  static PyObject *
diff -cr PyCVS/Objects/floatobject.c PyMem/Objects/floatobject.c
*** PyCVS/Objects/floatobject.c	Thu Feb 24 14:49:47 2000
--- PyMem/Objects/floatobject.c	Fri Feb 25 00:10:10 2000
***************
*** 35,40 ****
--- 35,41 ----
     for any kind of float exception without losing portability. */
  
  #include "Python.h"
+ #include "pycore.h"
  
  #include <ctype.h>
  #include "mymath.h"
***************
*** 97,105 ****
  #define BLOCK_SIZE	1000	/* 1K less typical malloc overhead */
  #define BHEAD_SIZE	8	/* Enough for a 64-bit pointer */
  #define N_FLOATOBJECTS	((BLOCK_SIZE - BHEAD_SIZE) / sizeof(PyFloatObject))
- 
- #define PyMem_MALLOC	malloc
- #define PyMem_FREE	free
  
  struct _floatblock {
  	struct _floatblock *next;
--- 98,103 ----
diff -cr PyCVS/Objects/frameobject.c PyMem/Objects/frameobject.c
*** PyCVS/Objects/frameobject.c	Thu Feb 24 14:49:47 2000
--- PyMem/Objects/frameobject.c	Fri Feb 25 00:15:10 2000
***************
*** 32,37 ****
--- 32,38 ----
  /* Frame object implementation */
  
  #include "Python.h"
+ #include "pycore.h"
  
  #include "compile.h"
  #include "frameobject.h"
***************
*** 179,186 ****
  		builtins = NULL;
  	if (free_list == NULL) {
  		f = (PyFrameObject *)
! 			malloc(sizeof(PyFrameObject) +
! 			       extras*sizeof(PyObject *));
  		if (f == NULL)
  			return (PyFrameObject *)PyErr_NoMemory();
  		f->ob_type = &PyFrame_Type;
--- 180,187 ----
  		builtins = NULL;
  	if (free_list == NULL) {
  		f = (PyFrameObject *)
! 			PyMem_MALLOC(sizeof(PyFrameObject) +
! 				     extras*sizeof(PyObject *));
  		if (f == NULL)
  			return (PyFrameObject *)PyErr_NoMemory();
  		f->ob_type = &PyFrame_Type;
***************
*** 191,198 ****
  		free_list = free_list->f_back;
  		if (f->f_nlocals + f->f_stacksize < extras) {
  			f = (PyFrameObject *)
! 				realloc(f, sizeof(PyFrameObject) +
! 					extras*sizeof(PyObject *));
  			if (f == NULL)
  				return (PyFrameObject *)PyErr_NoMemory();
  		}
--- 192,199 ----
  		free_list = free_list->f_back;
  		if (f->f_nlocals + f->f_stacksize < extras) {
  			f = (PyFrameObject *)
! 				PyMem_REALLOC(f, sizeof(PyFrameObject) +
! 					      extras*sizeof(PyObject *));
  			if (f == NULL)
  				return (PyFrameObject *)PyErr_NoMemory();
  		}
***************
*** 374,379 ****
  	while (free_list != NULL) {
  		PyFrameObject *f = free_list;
  		free_list = free_list->f_back;
! 		PyMem_DEL(f);
  	}
  }
--- 375,380 ----
  	while (free_list != NULL) {
  		PyFrameObject *f = free_list;
  		free_list = free_list->f_back;
! 		PyObject_DEL(f);
  	}
  }
diff -cr PyCVS/Objects/funcobject.c PyMem/Objects/funcobject.c
*** PyCVS/Objects/funcobject.c	Thu Feb 24 14:49:47 2000
--- PyMem/Objects/funcobject.c	Fri Feb 25 00:16:28 2000
***************
*** 32,37 ****
--- 32,39 ----
  /* Function object implementation */
  
  #include "Python.h"
+ #include "pycore.h"
+ 
  #include "compile.h"
  #include "structmember.h"
  
***************
*** 191,197 ****
  	Py_DECREF(op->func_name);
  	Py_XDECREF(op->func_defaults);
  	Py_XDECREF(op->func_doc);
! 	PyMem_DEL(op);
  }
  
  static PyObject*
--- 193,199 ----
  	Py_DECREF(op->func_name);
  	Py_XDECREF(op->func_defaults);
  	Py_XDECREF(op->func_doc);
! 	PyObject_DEL(op);
  }
  
  static PyObject*
diff -cr PyCVS/Objects/intobject.c PyMem/Objects/intobject.c
*** PyCVS/Objects/intobject.c	Thu Feb 24 14:49:47 2000
--- PyMem/Objects/intobject.c	Fri Feb 25 00:24:34 2000
***************
*** 32,37 ****
--- 32,39 ----
  /* Integer object implementation */
  
  #include "Python.h"
+ #include "pycore.h"
+ 
  #include <ctype.h>
  
  #ifdef HAVE_LIMITS_H
***************
*** 93,101 ****
  #define BLOCK_SIZE	1000	/* 1K less typical malloc overhead */
  #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;
--- 95,100 ----
diff -cr PyCVS/Objects/listobject.c PyMem/Objects/listobject.c
*** PyCVS/Objects/listobject.c	Thu Feb 24 14:49:47 2000
--- PyMem/Objects/listobject.c	Fri Feb 25 09:17:05 2000
***************
*** 32,37 ****
--- 32,38 ----
  /* List object implementation */
  
  #include "Python.h"
+ #include "pycore.h"
  
  #ifdef STDC_HEADERS
  #include <stddef.h>
***************
*** 70,76 ****
  	if (nbytes / sizeof(PyObject *) != (size_t)size) {
  		return PyErr_NoMemory();
  	}
! 	op = (PyListObject *) malloc(sizeof(PyListObject));
  	if (op == NULL) {
  		return PyErr_NoMemory();
  	}
--- 71,77 ----
  	if (nbytes / sizeof(PyObject *) != (size_t)size) {
  		return PyErr_NoMemory();
  	}
! 	op = (PyListObject *) PyMem_MALLOC(sizeof(PyListObject));
  	if (op == NULL) {
  		return PyErr_NoMemory();
  	}
***************
*** 78,86 ****
  		op->ob_item = NULL;
  	}
  	else {
! 		op->ob_item = (PyObject **) malloc(nbytes);
  		if (op->ob_item == NULL) {
! 			free((ANY *)op);
  			return PyErr_NoMemory();
  		}
  	}
--- 79,87 ----
  		op->ob_item = NULL;
  	}
  	else {
! 		op->ob_item = PyMem_NEW(PyObject *, size);
  		if (op->ob_item == NULL) {
! 			PyMem_FREE(op);
  			return PyErr_NoMemory();
  		}
  	}
***************
*** 224,232 ****
  		while (--i >= 0) {
  			Py_XDECREF(op->ob_item[i]);
  		}
! 		free((ANY *)op->ob_item);
  	}
! 	free((ANY *)op);
  }
  
  static int
--- 225,233 ----
  		while (--i >= 0) {
  			Py_XDECREF(op->ob_item[i]);
  		}
! 		PyMem_DEL(op->ob_item);
  	}
! 	PyObject_DEL(op);
  }
  
  static int
***************
*** 479,485 ****
  	else { /* Insert d items; recycle ihigh-ilow items */
  		NRESIZE(item, PyObject *, a->ob_size + d);
  		if (item == NULL) {
! 			PyMem_XDEL(recycle);
  			PyErr_NoMemory();
  			return -1;
  		}
--- 480,487 ----
  	else { /* Insert d items; recycle ihigh-ilow items */
  		NRESIZE(item, PyObject *, a->ob_size + d);
  		if (item == NULL) {
! 			if (recycle != NULL)
! 				PyMem_DEL(recycle);
  			PyErr_NoMemory();
  			return -1;
  		}
diff -cr PyCVS/Objects/longobject.c PyMem/Objects/longobject.c
*** PyCVS/Objects/longobject.c	Thu Feb 24 14:49:47 2000
--- PyMem/Objects/longobject.c	Fri Feb 25 00:40:44 2000
***************
*** 34,39 ****
--- 34,41 ----
  /* XXX The functional organization of this file is terrible */
  
  #include "Python.h"
+ #include "pycore.h"
+ 
  #include "longintrepr.h"
  #include "mymath.h"
  
***************
*** 968,974 ****
  long_dealloc(v)
  	PyObject *v;
  {
! 	PyMem_DEL(v);
  }
  
  static PyObject *
--- 970,976 ----
  long_dealloc(v)
  	PyObject *v;
  {
! 	PyObject_DEL(v);
  }
  
  static PyObject *
diff -cr PyCVS/Objects/methodobject.c PyMem/Objects/methodobject.c
*** PyCVS/Objects/methodobject.c	Thu Feb 24 14:49:47 2000
--- PyMem/Objects/methodobject.c	Fri Feb 25 00:42:41 2000
***************
*** 32,37 ****
--- 32,38 ----
  /* Method object implementation */
  
  #include "Python.h"
+ #include "pycore.h"
  
  #include "token.h"
  
***************
*** 288,293 ****
  	while (free_list) {
  		PyCFunctionObject *v = free_list;
  		free_list = (PyCFunctionObject *)(v->m_self);
! 		PyMem_DEL(v);
  	}
  }
--- 289,294 ----
  	while (free_list) {
  		PyCFunctionObject *v = free_list;
  		free_list = (PyCFunctionObject *)(v->m_self);
! 		PyObject_DEL(v);
  	}
  }
diff -cr PyCVS/Objects/moduleobject.c PyMem/Objects/moduleobject.c
*** PyCVS/Objects/moduleobject.c	Thu Feb 24 14:49:47 2000
--- PyMem/Objects/moduleobject.c	Fri Feb 25 00:44:23 2000
***************
*** 32,37 ****
--- 32,38 ----
  /* Module object implementation */
  
  #include "Python.h"
+ #include "pycore.h"
  
  typedef struct {
  	PyObject_HEAD
***************
*** 170,176 ****
  		_PyModule_Clear((PyObject *)m);
  		Py_DECREF(m->md_dict);
  	}
! 	free((char *)m);
  }
  
  static PyObject *
--- 171,177 ----
  		_PyModule_Clear((PyObject *)m);
  		Py_DECREF(m->md_dict);
  	}
! 	PyObject_DEL(m);
  }
  
  static PyObject *
diff -cr PyCVS/Objects/object.c PyMem/Objects/object.c
*** PyCVS/Objects/object.c	Thu Feb 24 14:49:47 2000
--- PyMem/Objects/object.c	Fri Feb 25 00:53:10 2000
***************
*** 32,37 ****
--- 32,38 ----
  /* Generic object operations; and implementation of None (NoObject) */
  
  #include "Python.h"
+ #include "pycore.h"
  
  #if defined( Py_TRACE_REFS ) || defined( Py_REF_DEBUG )
  DL_IMPORT(long) _Py_RefTotal;
***************
*** 119,125 ****
  #endif
  {
  #ifndef MS_COREDLL
! 	PyObject *op = (PyObject *) malloc(tp->tp_basicsize);
  #endif
  	if (op == NULL)
  		return PyErr_NoMemory();
--- 120,126 ----
  #endif
  {
  #ifndef MS_COREDLL
! 	PyObject *op = (PyObject *) PyMem_MALLOC(tp->tp_basicsize);
  #endif
  	if (op == NULL)
  		return PyErr_NoMemory();
***************
*** 143,149 ****
  {
  #ifndef MS_COREDLL
  	PyVarObject *op = (PyVarObject *)
! 		malloc(tp->tp_basicsize + size * tp->tp_itemsize);
  #endif
  	if (op == NULL)
  		return (PyVarObject *)PyErr_NoMemory();
--- 144,150 ----
  {
  #ifndef MS_COREDLL
  	PyVarObject *op = (PyVarObject *)
! 		PyMem_MALLOC(tp->tp_basicsize + size * tp->tp_itemsize);
  #endif
  	if (op == NULL)
  		return (PyVarObject *)PyErr_NoMemory();
***************
*** 153,158 ****
--- 154,170 ----
  	return op;
  }
  
+ void
+ _PyObject_Del(op)
+ 	PyObject *op;
+ {
+ #ifndef MS_COREDLL
+ 	PyMem_FREE(op);
+ #else
+ 	free((ANY *)(op));
+ #endif
+ }
+ 
  int
  PyObject_Print(op, fp, flags)
  	PyObject *op;
***************
*** 754,760 ****
  	if (nbytes == 0)
  		nbytes = _PyMem_EXTRA;
  #endif
! 	p = malloc(nbytes);
  	if (p != NULL)
  		return p;
  	else {
--- 766,772 ----
  	if (nbytes == 0)
  		nbytes = _PyMem_EXTRA;
  #endif
! 	p = PyMem_MALLOC(nbytes);
  	if (p != NULL)
  		return p;
  	else {
***************
*** 772,778 ****
  	if (nbytes == 0)
  		nbytes = _PyMem_EXTRA;
  #endif
! 	p = realloc(p, nbytes);
  	if (p != NULL)
  		return p;
  	else {
--- 784,790 ----
  	if (nbytes == 0)
  		nbytes = _PyMem_EXTRA;
  #endif
! 	p = PyMem_REALLOC(p, nbytes);
  	if (p != NULL)
  		return p;
  	else {
***************
*** 785,823 ****
  Py_Free(p)
  	ANY *p;
  {
! 	free(p);
! }
! 
! /* The PyMem_{Malloc,Realloc} wrappers don't call anything on failure */
! 
! ANY *
! PyMem_Malloc(nbytes)
! 	size_t nbytes;
! {
! #if _PyMem_EXTRA > 0
! 	if (nbytes == 0)
! 		nbytes = _PyMem_EXTRA;
! #endif
! 	return malloc(nbytes);
! }
! 
! ANY *
! PyMem_Realloc(p, nbytes)
! 	ANY *p;
! 	size_t nbytes;
! {
! #if _PyMem_EXTRA > 0
! 	if (nbytes == 0)
! 		nbytes = _PyMem_EXTRA;
! #endif
! 	return realloc(p, nbytes);
! }
! 
! void
! PyMem_Free(p)
! 	ANY *p;
! {
! 	free(p);
  }
  
  
--- 797,803 ----
  Py_Free(p)
  	ANY *p;
  {
! 	PyMem_FREE(p);
  }
  
  
diff -cr PyCVS/Objects/rangeobject.c PyMem/Objects/rangeobject.c
*** PyCVS/Objects/rangeobject.c	Thu Feb 24 14:49:47 2000
--- PyMem/Objects/rangeobject.c	Fri Feb 25 00:54:48 2000
***************
*** 32,37 ****
--- 32,38 ----
  /* Range object implementation */
  
  #include "Python.h"
+ #include "pycore.h"
  
  typedef struct {
  	PyObject_HEAD
***************
*** 61,67 ****
  range_dealloc(r)
  	rangeobject *r;
  {
! 	PyMem_DEL(r);
  }
  
  static PyObject *
--- 62,68 ----
  range_dealloc(r)
  	rangeobject *r;
  {
! 	PyObject_DEL(r);
  }
  
  static PyObject *
diff -cr PyCVS/Objects/sliceobject.c PyMem/Objects/sliceobject.c
*** PyCVS/Objects/sliceobject.c	Thu Feb 24 14:49:47 2000
--- PyMem/Objects/sliceobject.c	Fri Feb 25 00:57:04 2000
***************
*** 14,19 ****
--- 14,20 ----
  */
  
  #include "Python.h"
+ #include "pycore.h"
  
  static PyObject *
  ellipsis_repr(op)
***************
*** 57,64 ****
  	PyObject *stop;
  	PyObject *step;
  {
! 	PySliceObject *obj =
! 		(PySliceObject *) PyObject_NEW(PySliceObject, &PySlice_Type);
  
  	if (step == NULL) step = Py_None;
  	Py_INCREF(step);
--- 58,64 ----
  	PyObject *stop;
  	PyObject *step;
  {
! 	PySliceObject *obj = PyObject_NEW(PySliceObject, &PySlice_Type);
  
  	if (step == NULL) step = Py_None;
  	Py_INCREF(step);
***************
*** 115,121 ****
  	Py_DECREF(r->step);
  	Py_DECREF(r->start);
  	Py_DECREF(r->stop);
! 	PyMem_DEL(r);
  }
  
  static PyObject *
--- 115,121 ----
  	Py_DECREF(r->step);
  	Py_DECREF(r->start);
  	Py_DECREF(r->stop);
! 	PyObject_DEL(r);
  }
  
  static PyObject *
diff -cr PyCVS/Objects/stringobject.c PyMem/Objects/stringobject.c
*** PyCVS/Objects/stringobject.c	Thu Feb 24 14:49:47 2000
--- PyMem/Objects/stringobject.c	Fri Feb 25 09:22:58 2000
***************
*** 32,37 ****
--- 32,38 ----
  /* String object implementation */
  
  #include "Python.h"
+ #include "pycore.h"
  
  #include "mymath.h"
  #include <ctype.h>
***************
*** 93,99 ****
  	}
  #endif /* DONT_SHARE_SHORT_STRINGS */
  	op = (PyStringObject *)
! 		malloc(sizeof(PyStringObject) + size * sizeof(char));
  	if (op == NULL)
  		return PyErr_NoMemory();
  	op->ob_type = &PyString_Type;
--- 94,100 ----
  	}
  #endif /* DONT_SHARE_SHORT_STRINGS */
  	op = (PyStringObject *)
! 		PyMem_MALLOC(sizeof(PyStringObject) + size * sizeof(char));
  	if (op == NULL)
  		return PyErr_NoMemory();
  	op->ob_type = &PyString_Type;
***************
*** 143,149 ****
  	}
  #endif /* DONT_SHARE_SHORT_STRINGS */
  	op = (PyStringObject *)
! 		malloc(sizeof(PyStringObject) + size * sizeof(char));
  	if (op == NULL)
  		return PyErr_NoMemory();
  	op->ob_type = &PyString_Type;
--- 144,150 ----
  	}
  #endif /* DONT_SHARE_SHORT_STRINGS */
  	op = (PyStringObject *)
! 		PyMem_MALLOC(sizeof(PyStringObject) + size * sizeof(char));
  	if (op == NULL)
  		return PyErr_NoMemory();
  	op->ob_type = &PyString_Type;
***************
*** 172,178 ****
  string_dealloc(op)
  	PyObject *op;
  {
! 	PyMem_DEL(op);
  }
  
  int
--- 173,179 ----
  string_dealloc(op)
  	PyObject *op;
  {
! 	PyObject_DEL(op);
  }
  
  int
***************
*** 306,312 ****
  	}
  	size = a->ob_size + b->ob_size;
  	op = (PyStringObject *)
! 		malloc(sizeof(PyStringObject) + size * sizeof(char));
  	if (op == NULL)
  		return PyErr_NoMemory();
  	op->ob_type = &PyString_Type;
--- 307,313 ----
  	}
  	size = a->ob_size + b->ob_size;
  	op = (PyStringObject *)
! 		PyMem_MALLOC(sizeof(PyStringObject) + size * sizeof(char));
  	if (op == NULL)
  		return PyErr_NoMemory();
  	op->ob_type = &PyString_Type;
***************
*** 341,347 ****
  		return (PyObject *)a;
  	}
  	op = (PyStringObject *)
! 		malloc(sizeof(PyStringObject) + size * sizeof(char));
  	if (op == NULL)
  		return PyErr_NoMemory();
  	op->ob_type = &PyString_Type;
--- 342,348 ----
  		return (PyObject *)a;
  	}
  	op = (PyStringObject *)
! 		PyMem_MALLOC(sizeof(PyStringObject) + size * sizeof(char));
  	if (op == NULL)
  		return PyErr_NoMemory();
  	op->ob_type = &PyString_Type;
***************
*** 1369,1375 ****
  		goto return_same;
  	new_len = len + nfound*(sub_len - pat_len);
  
! 	new_s = (char *)malloc(new_len);
  	if (new_s == NULL) return NULL;
  
  	*out_len = new_len;
--- 1370,1376 ----
  		goto return_same;
  	new_len = len + nfound*(sub_len - pat_len);
  
! 	new_s = PyMem_NEW(char, new_len);
  	if (new_s == NULL) return NULL;
  
  	*out_len = new_len;
***************
*** 1441,1447 ****
  	}
  	else {
  		new = PyString_FromStringAndSize(new_s, out_len);
! 		free(new_s);
  	}
  	return new;
  }
--- 1442,1448 ----
  	}
  	else {
  		new = PyString_FromStringAndSize(new_s, out_len);
! 		PyMem_DEL(new_s);
  	}
  	return new;
  }
***************
*** 1646,1655 ****
  #endif
  	_Py_ForgetReference(v);
  	*pv = (PyObject *)
! 		realloc((char *)v,
! 			sizeof(PyStringObject) + newsize * sizeof(char));
  	if (*pv == NULL) {
! 		PyMem_DEL(v);
  		PyErr_NoMemory();
  		return -1;
  	}
--- 1647,1656 ----
  #endif
  	_Py_ForgetReference(v);
  	*pv = (PyObject *)
! 		PyMem_REALLOC((char *)v,
! 			      sizeof(PyStringObject) + newsize*sizeof(char));
  	if (*pv == NULL) {
! 		PyObject_DEL(v);
  		PyErr_NoMemory();
  		return -1;
  	}
diff -cr PyCVS/Objects/tupleobject.c PyMem/Objects/tupleobject.c
*** PyCVS/Objects/tupleobject.c	Thu Feb 24 14:49:47 2000
--- PyMem/Objects/tupleobject.c	Fri Feb 25 01:21:47 2000
***************
*** 32,37 ****
--- 32,38 ----
  /* Tuple object implementation */
  
  #include "Python.h"
+ #include "pycore.h"
  
  #ifndef MAXSAVESIZE
  #define MAXSAVESIZE	20
***************
*** 91,97 ****
  			return PyErr_NoMemory();
  		}
  		;
! 		op = (PyTupleObject *) malloc(nbytes);
  		if (op == NULL)
  			return PyErr_NoMemory();
  
--- 92,98 ----
  			return PyErr_NoMemory();
  		}
  		;
! 		op = (PyTupleObject *) PyMem_MALLOC(nbytes);
  		if (op == NULL)
  			return PyErr_NoMemory();
  
***************
*** 184,190 ****
  		}
  #endif
  	}
! 	free((ANY *)op);
  }
  
  static int
--- 185,191 ----
  		}
  #endif
  	}
! 	PyObject_DEL(op);
  }
  
  static int
***************
*** 467,477 ****
  		v->ob_item[i] = NULL;
  	}
  	sv = (PyTupleObject *)
! 		realloc((char *)v,
  			sizeof(PyTupleObject) + newsize * sizeof(PyObject *));
  	*pv = (PyObject *) sv;
  	if (sv == NULL) {
! 		PyMem_DEL(v);
  		PyErr_NoMemory();
  		return -1;
  	}
--- 468,478 ----
  		v->ob_item[i] = NULL;
  	}
  	sv = (PyTupleObject *)
! 		PyMem_REALLOC((char *)v,
  			sizeof(PyTupleObject) + newsize * sizeof(PyObject *));
  	*pv = (PyObject *) sv;
  	if (sv == NULL) {
! 		PyObject_DEL(v);
  		PyErr_NoMemory();
  		return -1;
  	}
***************
*** 505,511 ****
  		while (p) {
  			q = p;
  			p = (PyTupleObject *)(p->ob_item[0]);
! 			PyMem_DEL(q);
  		}
  	}
  #endif
--- 506,512 ----
  		while (p) {
  			q = p;
  			p = (PyTupleObject *)(p->ob_item[0]);
! 			PyObject_DEL(q);
  		}
  	}
  #endif
diff -cr PyCVS/Objects/typeobject.c PyMem/Objects/typeobject.c
*** PyCVS/Objects/typeobject.c	Thu Feb 24 14:49:47 2000
--- PyMem/Objects/typeobject.c	Fri Feb 25 01:24:08 2000
***************
*** 32,37 ****
--- 32,38 ----
  /* Type object implementation */
  
  #include "Python.h"
+ #include "pycore.h"
  
  /* Type object implementation */