summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_cursesmodule.c8
-rw-r--r--Modules/_sre.c8
-rw-r--r--Modules/_tkinter.c8
-rw-r--r--Modules/almodule.c8
-rw-r--r--Modules/arraymodule.c9
-rw-r--r--Modules/bsddbmodule.c8
-rw-r--r--Modules/cPickle.c14
-rw-r--r--Modules/cStringIO.c10
-rw-r--r--Modules/cdmodule.c8
-rw-r--r--Modules/clmodule.c4
-rw-r--r--Modules/dbmmodule.c4
-rw-r--r--Modules/dlmodule.c4
-rw-r--r--Modules/flmodule.c8
-rw-r--r--Modules/fmmodule.c4
-rw-r--r--Modules/gdbmmodule.c4
-rw-r--r--Modules/getpath.c2
-rw-r--r--Modules/linuxaudiodev.c4
-rw-r--r--Modules/md5module.c4
-rw-r--r--Modules/mmapmodule.c6
-rw-r--r--Modules/mpzmodule.c4
-rw-r--r--Modules/newmodule.c2
-rw-r--r--Modules/nismodule.c4
-rw-r--r--Modules/parsermodule.c8
-rw-r--r--Modules/pcremodule.c4
-rw-r--r--Modules/pyexpat.c4
-rw-r--r--Modules/readline.c14
-rw-r--r--Modules/regexmodule.c7
-rw-r--r--Modules/rotormodule.c28
-rw-r--r--Modules/selectmodule.c6
-rw-r--r--Modules/shamodule.c4
-rw-r--r--Modules/socketmodule.c18
-rw-r--r--Modules/stropmodule.c4
-rw-r--r--Modules/sunaudiodev.c6
-rw-r--r--Modules/svmodule.c8
-rw-r--r--Modules/threadmodule.c6
-rw-r--r--Modules/xxmodule.c4
-rw-r--r--Modules/zlibmodule.c6
37 files changed, 138 insertions, 124 deletions
diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c
index f76bf03..d654b29 100644
--- a/Modules/_cursesmodule.c
+++ b/Modules/_cursesmodule.c
@@ -273,7 +273,7 @@ PyCursesScreen_New(arg)
PyFileObject *in_fo;
PyFileObject *out_fo;
PyCursesScreenObject *xp;
- xp = PyObject_NEW(PyCursesScreenObject, &PyCursesScreen_Type);
+ xp = PyObject_New(PyCursesScreenObject, &PyCursesScreen_Type);
if (xp == NULL)
return NULL;
return (PyObject *)xp;
@@ -289,7 +289,7 @@ PyCursesWindow_New(win)
{
PyCursesWindowObject *wo;
- wo = PyObject_NEW(PyCursesWindowObject, &PyCursesWindow_Type);
+ wo = PyObject_New(PyCursesWindowObject, &PyCursesWindow_Type);
if (wo == NULL)
return NULL;
wo->win = win;
@@ -303,7 +303,7 @@ PyCursesWindow_Dealloc(wo)
{
if (wo->win != stdscr)
delwin(wo->win);
- PyMem_DEL(wo);
+ PyObject_Del(wo);
}
static PyObject *
@@ -1125,7 +1125,7 @@ PyCursesPad_New(pad)
WINDOW *pad;
{
PyCursesPadObject *po;
- po = PyObject_NEW(PyCursesPadObject, &PyCursesPad_Type);
+ po = PyObject_New(PyCursesPadObject, &PyCursesPad_Type);
if (po == NULL)
return NULL;
po->pad = pad;
diff --git a/Modules/_sre.c b/Modules/_sre.c
index 9eec035..47b80c5 100644
--- a/Modules/_sre.c
+++ b/Modules/_sre.c
@@ -848,7 +848,7 @@ _compile(PyObject* self_, PyObject* args)
&PyString_Type, &code, &groups, &groupindex))
return NULL;
- self = PyObject_NEW(PatternObject, &Pattern_Type);
+ self = PyObject_New(PatternObject, &Pattern_Type);
if (self == NULL)
return NULL;
@@ -886,7 +886,7 @@ _pattern_new_match(PatternObject* pattern, SRE_STATE* state,
if (status > 0) {
/* create match object (with room for extra group marks) */
- match = PyObject_NEW_VAR(MatchObject, &Match_Type, 2*pattern->groups);
+ match = PyObject_NewVar(MatchObject, &Match_Type, 2*pattern->groups);
if (match == NULL)
return NULL;
@@ -1002,7 +1002,7 @@ _pattern_dealloc(PatternObject* self)
Py_XDECREF(self->code);
Py_XDECREF(self->pattern);
Py_XDECREF(self->groupindex);
- PyMem_DEL(self);
+ PyObject_Del(self);
}
static PyObject*
@@ -1163,7 +1163,7 @@ _match_dealloc(MatchObject* self)
{
Py_XDECREF(self->string);
Py_DECREF(self->pattern);
- PyMem_DEL(self);
+ PyObject_Del(self);
}
static PyObject*
diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c
index 008378d..15cc7e7 100644
--- a/Modules/_tkinter.c
+++ b/Modules/_tkinter.c
@@ -469,7 +469,7 @@ Tkapp_New(screenName, baseName, className, interactive)
TkappObject *v;
char *argv0;
- v = PyObject_NEW(TkappObject, &Tkapp_Type);
+ v = PyObject_New(TkappObject, &Tkapp_Type);
if (v == NULL)
return NULL;
@@ -1640,7 +1640,7 @@ Tktt_New(func)
{
TkttObject *v;
- v = PyObject_NEW(TkttObject, &Tktt_Type);
+ v = PyObject_New(TkttObject, &Tktt_Type);
if (v == NULL)
return NULL;
@@ -1662,7 +1662,7 @@ Tktt_Dealloc(self)
Py_XDECREF(func);
- PyMem_DEL(self);
+ PyObject_Del(self);
}
static PyObject *
@@ -1910,7 +1910,7 @@ Tkapp_Dealloc(self)
ENTER_TCL
Tcl_DeleteInterp(Tkapp_Interp(self));
LEAVE_TCL
- PyMem_DEL(self);
+ PyObject_Del(self);
DisableEventHook();
}
diff --git a/Modules/almodule.c b/Modules/almodule.c
index 1033c07..c75fe89 100644
--- a/Modules/almodule.c
+++ b/Modules/almodule.c
@@ -648,7 +648,7 @@ newalcobject(ALconfig config)
{
alcobject *self;
- self = PyObject_NEW(alcobject, &Alctype);
+ self = PyObject_New(alcobject, &Alctype);
if (self == NULL)
return NULL;
/* XXXX Add your own initializers here */
@@ -667,7 +667,7 @@ alc_dealloc(self)
#else
(void) ALfreeconfig(self->config); /* ignore errors */
#endif
- PyMem_DEL(self);
+ PyObject_Del(self);
}
static PyObject *
@@ -1421,7 +1421,7 @@ newalpobject(ALport port)
{
alpobject *self;
- self = PyObject_NEW(alpobject, &Alptype);
+ self = PyObject_New(alpobject, &Alptype);
if (self == NULL)
return NULL;
/* XXXX Add your own initializers here */
@@ -1442,7 +1442,7 @@ alp_dealloc(self)
ALcloseport(self->port);
#endif
}
- PyMem_DEL(self);
+ PyObject_Del(self);
}
static PyObject *
diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c
index dcd931b..9a09c7d 100644
--- a/Modules/arraymodule.c
+++ b/Modules/arraymodule.c
@@ -346,7 +346,7 @@ newarrayobject(size, descr)
if (nbytes / descr->itemsize != (size_t)size) {
return PyErr_NoMemory();
}
- op = PyMem_NEW(arrayobject, 1);
+ op = PyObject_NewVar(arrayobject, &Arraytype, size);
if (op == NULL) {
return PyErr_NoMemory();
}
@@ -356,14 +356,11 @@ newarrayobject(size, descr)
else {
op->ob_item = PyMem_NEW(char, nbytes);
if (op->ob_item == NULL) {
- PyMem_DEL(op);
+ PyObject_Del(op);
return PyErr_NoMemory();
}
}
- op->ob_type = &Arraytype;
- op->ob_size = size;
op->ob_descr = descr;
- _Py_NewReference((PyObject *)op);
return (PyObject *) op;
}
@@ -466,7 +463,7 @@ array_dealloc(op)
{
if (op->ob_item != NULL)
PyMem_DEL(op->ob_item);
- PyMem_DEL(op);
+ PyObject_Del(op);
}
static int
diff --git a/Modules/bsddbmodule.c b/Modules/bsddbmodule.c
index 16178ed..97a8e8b 100644
--- a/Modules/bsddbmodule.c
+++ b/Modules/bsddbmodule.c
@@ -89,7 +89,7 @@ newdbhashobject(file, flags, mode,
bsddbobject *dp;
HASHINFO info;
- if ((dp = PyObject_NEW(bsddbobject, &Bsddbtype)) == NULL)
+ if ((dp = PyObject_New(bsddbobject, &Bsddbtype)) == NULL)
return NULL;
info.bsize = bsize;
@@ -143,7 +143,7 @@ newdbbtobject(file, flags, mode,
bsddbobject *dp;
BTREEINFO info;
- if ((dp = PyObject_NEW(bsddbobject, &Bsddbtype)) == NULL)
+ if ((dp = PyObject_New(bsddbobject, &Bsddbtype)) == NULL)
return NULL;
info.flags = btflags;
@@ -200,7 +200,7 @@ newdbrnobject(file, flags, mode,
bsddbobject *dp;
RECNOINFO info;
- if ((dp = PyObject_NEW(bsddbobject, &Bsddbtype)) == NULL)
+ if ((dp = PyObject_New(bsddbobject, &Bsddbtype)) == NULL)
return NULL;
info.flags = rnflags;
@@ -261,7 +261,7 @@ bsddb_dealloc(dp)
"Python bsddb: close errno %d in dealloc\n",
errno);
}
- PyMem_DEL(dp);
+ PyObject_Del(dp);
}
#ifdef WITH_THREAD
diff --git a/Modules/cPickle.c b/Modules/cPickle.c
index aa2c7cb..73cb6ba 100644
--- a/Modules/cPickle.c
+++ b/Modules/cPickle.c
@@ -171,7 +171,7 @@ Pdata_dealloc(Pdata *self) {
if (self->data) free(self->data);
- PyMem_DEL(self);
+ PyObject_Del(self);
}
static PyTypeObject PdataType = {
@@ -186,7 +186,7 @@ static PyObject *
Pdata_New() {
Pdata *self;
- UNLESS (self = PyObject_NEW(Pdata, &PdataType)) return NULL;
+ UNLESS (self = PyObject_New(Pdata, &PdataType)) return NULL;
self->size=8;
self->length=0;
self->data=malloc(self->size * sizeof(PyObject*));
@@ -2132,7 +2132,7 @@ static Picklerobject *
newPicklerobject(PyObject *file, int bin) {
Picklerobject *self;
- UNLESS (self = PyObject_NEW(Picklerobject, &Picklertype))
+ UNLESS (self = PyObject_New(Picklerobject, &Picklertype))
return NULL;
self->fp = NULL;
@@ -2243,7 +2243,7 @@ Pickler_dealloc(Picklerobject *self) {
free(self->write_buf);
}
- PyMem_DEL(self);
+ PyObject_Del(self);
}
@@ -2885,7 +2885,7 @@ Instance_New(PyObject *cls, PyObject *args) {
PyInstanceObject *inst;
PyErr_Clear();
- UNLESS (inst=PyObject_NEW(PyInstanceObject, &PyInstance_Type))
+ UNLESS (inst=PyObject_New(PyInstanceObject, &PyInstance_Type))
goto err;
inst->in_class=(PyClassObject*)cls;
Py_INCREF(cls);
@@ -4036,7 +4036,7 @@ static Unpicklerobject *
newUnpicklerobject(PyObject *f) {
Unpicklerobject *self;
- UNLESS (self = PyObject_NEW(Unpicklerobject, &Unpicklertype))
+ UNLESS (self = PyObject_New(Unpicklerobject, &Unpicklertype))
return NULL;
self->file = NULL;
@@ -4141,7 +4141,7 @@ Unpickler_dealloc(Unpicklerobject *self) {
free(self->buf);
}
- PyMem_DEL(self);
+ PyObject_Del(self);
}
diff --git a/Modules/cStringIO.c b/Modules/cStringIO.c
index e816178..557545f 100644
--- a/Modules/cStringIO.c
+++ b/Modules/cStringIO.c
@@ -56,7 +56,7 @@ static char cStringIO_module_documentation[] =
"\n"
"This module provides a simple useful replacement for\n"
"the StringIO module that is written in C. It does not provide the\n"
-"full generality if StringIO, but it provides anough for most\n"
+"full generality if StringIO, but it provides enough for most\n"
"applications and is especially useful in conjuction with the\n"
"pickle module.\n"
"\n"
@@ -407,7 +407,7 @@ static void
O_dealloc(Oobject *self) {
if (self->buf != NULL)
free(self->buf);
- PyMem_DEL(self);
+ PyObject_Del(self);
}
static PyObject *
@@ -465,7 +465,7 @@ static PyObject *
newOobject(int size) {
Oobject *self;
- self = PyObject_NEW(Oobject, &Otype);
+ self = PyObject_New(Oobject, &Otype);
if (self == NULL)
return NULL;
self->pos=0;
@@ -536,7 +536,7 @@ static struct PyMethodDef I_methods[] = {
static void
I_dealloc(Iobject *self) {
Py_XDECREF(self->pbuf);
- PyMem_DEL(self);
+ PyObject_Del(self);
}
static PyObject *
@@ -586,7 +586,7 @@ newIobject(PyObject *s) {
}
buf = PyString_AS_STRING(s);
size = PyString_GET_SIZE(s);
- UNLESS(self = PyObject_NEW(Iobject, &Itype)) return NULL;
+ UNLESS(self = PyObject_New(Iobject, &Itype)) return NULL;
Py_INCREF(s);
self->buf=buf;
self->string_size=size;
diff --git a/Modules/cdmodule.c b/Modules/cdmodule.c
index 1b414c1..4a04e43 100644
--- a/Modules/cdmodule.c
+++ b/Modules/cdmodule.c
@@ -447,7 +447,7 @@ cdplayer_dealloc(self)
{
if (self->ob_cdplayer != NULL)
CDclose(self->ob_cdplayer);
- PyMem_DEL(self);
+ PyObject_Del(self);
}
static PyObject *
@@ -483,7 +483,7 @@ newcdplayerobject(cdp)
{
cdplayerobject *p;
- p = PyObject_NEW(cdplayerobject, &CdPlayertype);
+ p = PyObject_New(cdplayerobject, &CdPlayertype);
if (p == NULL)
return NULL;
p->ob_cdplayer = cdp;
@@ -761,7 +761,7 @@ cdparser_dealloc(self)
self->ob_cdcallbacks[i].ob_cdcallbackarg = NULL;
}
CDdeleteparser(self->ob_cdparser);
- PyMem_DEL(self);
+ PyObject_Del(self);
}
static PyObject *
@@ -799,7 +799,7 @@ newcdparserobject(cdp)
cdparserobject *p;
int i;
- p = PyObject_NEW(cdparserobject, &CdParsertype);
+ p = PyObject_New(cdparserobject, &CdParsertype);
if (p == NULL)
return NULL;
p->ob_cdparser = cdp;
diff --git a/Modules/clmodule.c b/Modules/clmodule.c
index 05b00da..976346a 100644
--- a/Modules/clmodule.c
+++ b/Modules/clmodule.c
@@ -673,7 +673,7 @@ cl_dealloc(PyObject *self)
else
clCloseDecompressor(SELF->ob_compressorHdl);
}
- PyMem_DEL(self);
+ PyObject_Del(self);
}
static PyObject *
@@ -713,7 +713,7 @@ doOpen(PyObject *self, PyObject *args, int (*open_func)(int, CL_Handle *),
if (!PyArg_Parse(args, "i", &scheme))
return NULL;
- new = PyObject_NEW(clobject, &Cltype);
+ new = PyObject_New(clobject, &Cltype);
if (new == NULL)
return NULL;
diff --git a/Modules/dbmmodule.c b/Modules/dbmmodule.c
index 501c3f4..d4fc1bf 100644
--- a/Modules/dbmmodule.c
+++ b/Modules/dbmmodule.c
@@ -62,7 +62,7 @@ int mode;
{
dbmobject *dp;
- dp = PyObject_NEW(dbmobject, &Dbmtype);
+ dp = PyObject_New(dbmobject, &Dbmtype);
if (dp == NULL)
return NULL;
dp->di_size = -1;
@@ -82,7 +82,7 @@ dbm_dealloc(dp)
{
if ( dp->di_dbm )
dbm_close(dp->di_dbm);
- PyMem_DEL(dp);
+ PyObject_Del(dp);
}
static int
diff --git a/Modules/dlmodule.c b/Modules/dlmodule.c
index 76d0540..b40e05e 100644
--- a/Modules/dlmodule.c
+++ b/Modules/dlmodule.c
@@ -54,7 +54,7 @@ newdlobject(handle)
PyUnivPtr *handle;
{
dlobject *xp;
- xp = PyObject_NEW(dlobject, &Dltype);
+ xp = PyObject_New(dlobject, &Dltype);
if (xp == NULL)
return NULL;
xp->dl_handle = handle;
@@ -67,7 +67,7 @@ dl_dealloc(xp)
{
if (xp->dl_handle != NULL)
dlclose(xp->dl_handle);
- PyMem_DEL(xp);
+ PyObject_Del(xp);
}
static PyObject *
diff --git a/Modules/flmodule.c b/Modules/flmodule.c
index c921d4b..c6ce439 100644
--- a/Modules/flmodule.c
+++ b/Modules/flmodule.c
@@ -332,7 +332,7 @@ generic_dealloc(g)
fl_free_object(g->ob_generic);
Py_XDECREF(g->ob_callback);
Py_XDECREF(g->ob_callback_arg);
- PyMem_DEL(g);
+ PyObject_Del(g);
}
#define OFF(x) offsetof(FL_OBJECT, x)
@@ -461,7 +461,7 @@ newgenericobject(generic, methods)
PyMethodDef *methods;
{
genericobject *g;
- g = PyObject_NEW(genericobject, &GenericObjecttype);
+ g = PyObject_New(genericobject, &GenericObjecttype);
if (g == NULL)
return NULL;
g-> ob_generic = generic;
@@ -1852,7 +1852,7 @@ form_dealloc(f)
if (f->ob_form->visible)
fl_hide_form(f->ob_form);
fl_free_form(f->ob_form);
- PyMem_DEL(f);
+ PyObject_Del(f);
}
#define OFF(x) offsetof(FL_FORM, x)
@@ -1931,7 +1931,7 @@ newformobject(form)
FL_FORM *form;
{
formobject *f;
- f = PyObject_NEW(formobject, &Formtype);
+ f = PyObject_New(formobject, &Formtype);
if (f == NULL)
return NULL;
f->ob_form = form;
diff --git a/Modules/fmmodule.c b/Modules/fmmodule.c
index dd5b397..21f08d8 100644
--- a/Modules/fmmodule.c
+++ b/Modules/fmmodule.c
@@ -59,7 +59,7 @@ newfhobject(fh)
"error creating new font handle");
return NULL;
}
- fhp = PyObject_NEW(fhobject, &Fhtype);
+ fhp = PyObject_New(fhobject, &Fhtype);
if (fhp == NULL)
return NULL;
fhp->fh_fh = fh;
@@ -196,7 +196,7 @@ fh_dealloc(fhp)
fhobject *fhp;
{
fmfreefont(fhp->fh_fh);
- PyMem_DEL(fhp);
+ PyObject_Del(fhp);
}
static PyTypeObject Fhtype = {
diff --git a/Modules/gdbmmodule.c b/Modules/gdbmmodule.c
index 96b5866..066cf3b 100644
--- a/Modules/gdbmmodule.c
+++ b/Modules/gdbmmodule.c
@@ -93,7 +93,7 @@ int mode;
{
dbmobject *dp;
- dp = PyObject_NEW(dbmobject, &Dbmtype);
+ dp = PyObject_New(dbmobject, &Dbmtype);
if (dp == NULL)
return NULL;
dp->di_size = -1;
@@ -117,7 +117,7 @@ dbm_dealloc(dp)
{
if ( dp->di_dbm )
gdbm_close(dp->di_dbm);
- PyMem_DEL(dp);
+ PyObject_Del(dp);
}
static int
diff --git a/Modules/getpath.c b/Modules/getpath.c
index 78b4915..78568137 100644
--- a/Modules/getpath.c
+++ b/Modules/getpath.c
@@ -529,7 +529,7 @@ calculate_path()
bufsz += strlen(exec_prefix) + 1;
/* This is the only malloc call in this file */
- buf = malloc(bufsz);
+ buf = PyMem_Malloc(bufsz);
if (buf == NULL) {
/* We can't exit, so print a warning and limp along */
diff --git a/Modules/linuxaudiodev.c b/Modules/linuxaudiodev.c
index 393df05..aac742a 100644
--- a/Modules/linuxaudiodev.c
+++ b/Modules/linuxaudiodev.c
@@ -104,7 +104,7 @@ newladobject(PyObject *arg)
}
/* Create and initialize the object */
- if ((xp = PyObject_NEW(lad_t, &Ladtype)) == NULL) {
+ if ((xp = PyObject_New(lad_t, &Ladtype)) == NULL) {
close(fd);
return NULL;
}
@@ -118,7 +118,7 @@ static void
lad_dealloc(lad_t *xp)
{
close(xp->x_fd);
- PyMem_DEL(xp);
+ PyObject_Del(xp);
}
static PyObject *
diff --git a/Modules/md5module.c b/Modules/md5module.c
index 3c001ae..6856c68 100644
--- a/Modules/md5module.c
+++ b/Modules/md5module.c
@@ -56,7 +56,7 @@ newmd5object()
{
md5object *md5p;
- md5p = PyObject_NEW(md5object, &MD5type);
+ md5p = PyObject_New(md5object, &MD5type);
if (md5p == NULL)
return NULL;
@@ -71,7 +71,7 @@ static void
md5_dealloc(md5p)
md5object *md5p;
{
- PyMem_DEL(md5p);
+ PyObject_Del(md5p);
}
diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c
index a79812d..fcbb484 100644
--- a/Modules/mmapmodule.c
+++ b/Modules/mmapmodule.c
@@ -69,7 +69,7 @@ mmap_object_dealloc(mmap_object * m_obj)
}
#endif /* UNIX */
- PyMem_DEL(m_obj);
+ PyObject_Del(m_obj);
}
static PyObject *
@@ -706,7 +706,7 @@ new_mmap_object (PyObject * self, PyObject * args, PyObject *kwdict)
)
return NULL;
- m_obj = PyObject_NEW (mmap_object, &mmap_object_type);
+ m_obj = PyObject_New (mmap_object, &mmap_object_type);
if (m_obj == NULL) {return NULL;}
m_obj->size = (size_t) map_size;
m_obj->pos = (size_t) 0;
@@ -757,7 +757,7 @@ new_mmap_object (PyObject * self, PyObject * args)
fseek(&_iob[fileno], 0, SEEK_SET);
}
- m_obj = PyObject_NEW (mmap_object, &mmap_object_type);
+ m_obj = PyObject_New (mmap_object, &mmap_object_type);
if (fh) {
m_obj->file_handle = fh;
diff --git a/Modules/mpzmodule.c b/Modules/mpzmodule.c
index e701d85..1aaf787 100644
--- a/Modules/mpzmodule.c
+++ b/Modules/mpzmodule.c
@@ -123,7 +123,7 @@ newmpzobject()
#ifdef MPZ_DEBUG
fputs( "mpz_object() called...\n", stderr );
#endif /* def MPZ_DEBUG */
- mpzp = PyObject_NEW(mpzobject, &MPZtype);
+ mpzp = PyObject_New(mpzobject, &MPZtype);
if (mpzp == NULL)
return NULL;
@@ -285,7 +285,7 @@ mpz_dealloc(mpzp)
fputs( "mpz_dealloc() called...\n", stderr );
#endif /* def MPZ_DEBUG */
mpz_clear(&mpzp->mpz);
- PyMem_DEL(mpzp);
+ PyObject_Del(mpzp);
} /* mpz_dealloc() */
diff --git a/Modules/newmodule.c b/Modules/newmodule.c
index 2758f14..fa0dc8b 100644
--- a/Modules/newmodule.c
+++ b/Modules/newmodule.c
@@ -49,7 +49,7 @@ new_instance(unused, args)
&PyClass_Type, &klass,
&PyDict_Type, &dict))
return NULL;
- inst = PyObject_NEW(PyInstanceObject, &PyInstance_Type);
+ inst = PyObject_New(PyInstanceObject, &PyInstance_Type);
if (inst == NULL)
return NULL;
Py_INCREF(klass);
diff --git a/Modules/nismodule.c b/Modules/nismodule.c
index 04f27f2..8943729 100644
--- a/Modules/nismodule.c
+++ b/Modules/nismodule.c
@@ -353,11 +353,11 @@ nis_maplist ()
if (list->stat != NIS_TRUE)
goto finally;
- PyMem_DEL(server);
+ free(server);
return list->maps;
finally:
- PyMem_DEL(server);
+ free(server);
return NULL;
}
diff --git a/Modules/parsermodule.c b/Modules/parsermodule.c
index 6a8d38c..9b9baf0 100644
--- a/Modules/parsermodule.c
+++ b/Modules/parsermodule.c
@@ -295,7 +295,7 @@ parser_compare(PyAST_Object *left, PyAST_Object *right)
static PyObject*
parser_newastobject(node *ast, int type)
{
- PyAST_Object* o = PyObject_NEW(PyAST_Object, &PyAST_Type);
+ PyAST_Object* o = PyObject_New(PyAST_Object, &PyAST_Type);
if (o != 0) {
o->ast_node = ast;
@@ -317,7 +317,7 @@ static void
parser_free(PyAST_Object *ast)
{
PyNode_Free(ast->ast_node);
- PyMem_DEL(ast);
+ PyObject_Del(ast);
}
@@ -790,10 +790,10 @@ build_node_children(PyObject *tuple, node *root, int *line_num)
PyObject *temp = PySequence_GetItem(elem, 1);
/* check_terminal_tuple() already verified it's a string */
- strn = (char *)malloc(PyString_GET_SIZE(temp) + 1);
+ strn = (char *)PyMem_MALLOC(PyString_GET_SIZE(temp) + 1);
if (strn != NULL)
(void) strcpy(strn, PyString_AS_STRING(temp));
- Py_XDECREF(temp);
+ Py_DECREF(temp);
if (PyObject_Length(elem) == 3) {
PyObject* temp = PySequence_GetItem(elem, 2);
diff --git a/Modules/pcremodule.c b/Modules/pcremodule.c
index 4d2aa72..6b9f960 100644
--- a/Modules/pcremodule.c
+++ b/Modules/pcremodule.c
@@ -79,7 +79,7 @@ newPcreObject(arg)
PyObject *arg;
{
PcreObject *self;
- self = PyObject_NEW(PcreObject, &Pcre_Type);
+ self = PyObject_New(PcreObject, &Pcre_Type);
if (self == NULL)
return NULL;
self->regex = NULL;
@@ -95,7 +95,7 @@ PyPcre_dealloc(self)
{
if (self->regex) (pcre_free)(self->regex);
if (self->regex_extra) (pcre_free)(self->regex_extra);
- PyMem_DEL(self);
+ PyObject_Del(self);
}
diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c
index e98f393..f8b3bce 100644
--- a/Modules/pyexpat.c
+++ b/Modules/pyexpat.c
@@ -471,7 +471,7 @@ newxmlparseobject( char *encoding, char *namespace_separator){
int i;
xmlparseobject *self;
- self = PyObject_NEW(xmlparseobject, &Xmlparsetype);
+ self = PyObject_New(xmlparseobject, &Xmlparsetype);
if (self == NULL)
return NULL;
@@ -512,7 +512,7 @@ xmlparse_dealloc( xmlparseobject *self )
for( i=0; handler_info[i].name!=NULL; i++ ){
Py_XDECREF( self->handlers[i] );
}
- PyMem_DEL(self);
+ PyObject_Del(self);
}
static int handlername2int( const char *name ){
diff --git a/Modules/readline.c b/Modules/readline.c
index d4ba3f8..37baf8c 100644
--- a/Modules/readline.c
+++ b/Modules/readline.c
@@ -377,7 +377,7 @@ call_readline(prompt)
char *prompt;
{
int n;
- char *p;
+ char *p, *q;
RETSIGTYPE (*old_inthandler)();
old_inthandler = signal(SIGINT, onintr);
if (setjmp(jbuf)) {
@@ -391,8 +391,10 @@ call_readline(prompt)
rl_event_hook = PyOS_InputHook;
p = readline(prompt);
signal(SIGINT, old_inthandler);
+
+ /* We must return a buffer allocated with PyMem_Malloc. */
if (p == NULL) {
- p = malloc(1);
+ p = PyMem_Malloc(1);
if (p != NULL)
*p = '\0';
return p;
@@ -400,10 +402,16 @@ call_readline(prompt)
n = strlen(p);
if (n > 0)
add_history(p);
- if ((p = realloc(p, n+2)) != NULL) {
+ /* Copy the malloc'ed buffer into a PyMem_Malloc'ed one and
+ release the original. */
+ q = p;
+ p = PyMem_Malloc(n+2);
+ if (p != NULL) {
+ strncpy(p, q, n);
p[n] = '\n';
p[n+1] = '\0';
}
+ free(q);
return p;
}
diff --git a/Modules/regexmodule.c b/Modules/regexmodule.c
index 4fbf5c8..92d3b71 100644
--- a/Modules/regexmodule.c
+++ b/Modules/regexmodule.c
@@ -64,13 +64,14 @@ static void
reg_dealloc(re)
regexobject *re;
{
- PyMem_XDEL(re->re_patbuf.buffer);
+ if (re->re_patbuf.buffer)
+ PyMem_DEL(re->re_patbuf.buffer);
Py_XDECREF(re->re_translate);
Py_XDECREF(re->re_lastok);
Py_XDECREF(re->re_groupindex);
Py_XDECREF(re->re_givenpat);
Py_XDECREF(re->re_realpat);
- PyMem_DEL(re);
+ PyObject_Del(re);
}
static PyObject *
@@ -418,7 +419,7 @@ newregexobject(pattern, translate, givenpat, groupindex)
"translation table must be 256 bytes");
return NULL;
}
- re = PyObject_NEW(regexobject, &Regextype);
+ re = PyObject_New(regexobject, &Regextype);
if (re != NULL) {
char *error;
re->re_patbuf.buffer = NULL;
diff --git a/Modules/rotormodule.c b/Modules/rotormodule.c
index b1fef39..3d570f7 100644
--- a/Modules/rotormodule.c
+++ b/Modules/rotormodule.c
@@ -178,7 +178,7 @@ rotorobj_new(num_rotors, key)
{
Rotorobj *xp;
- xp = PyObject_NEW(Rotorobj, &Rotor_Type);
+ xp = PyObject_New(Rotorobj, &Rotor_Type);
if (xp == NULL)
return NULL;
set_key(xp, key);
@@ -204,10 +204,14 @@ rotorobj_new(num_rotors, key)
return xp;
finally:
- PyMem_XDEL(xp->e_rotor);
- PyMem_XDEL(xp->d_rotor);
- PyMem_XDEL(xp->positions);
- PyMem_XDEL(xp->advances);
+ if (xp->e_rotor)
+ PyMem_DEL(xp->e_rotor);
+ if (xp->d_rotor)
+ PyMem_DEL(xp->d_rotor);
+ if (xp->positions)
+ PyMem_DEL(xp->positions);
+ if (xp->advances)
+ PyMem_DEL(xp->advances);
Py_DECREF(xp);
return (Rotorobj*)PyErr_NoMemory();
}
@@ -473,11 +477,15 @@ static void
rotor_dealloc(xp)
Rotorobj *xp;
{
- PyMem_XDEL(xp->e_rotor);
- PyMem_XDEL(xp->d_rotor);
- PyMem_XDEL(xp->positions);
- PyMem_XDEL(xp->advances);
- PyMem_DEL(xp);
+ if (xp->e_rotor)
+ PyMem_DEL(xp->e_rotor);
+ if (xp->d_rotor)
+ PyMem_DEL(xp->d_rotor);
+ if (xp->positions)
+ PyMem_DEL(xp->positions);
+ if (xp->advances)
+ PyMem_DEL(xp->advances);
+ PyObject_Del(xp);
}
static PyObject *
diff --git a/Modules/selectmodule.c b/Modules/selectmodule.c
index b48eb54..fb46fc3 100644
--- a/Modules/selectmodule.c
+++ b/Modules/selectmodule.c
@@ -278,9 +278,9 @@ select_select(self, args)
wfd2obj = PyMem_NEW(pylist, FD_SETSIZE + 3);
efd2obj = PyMem_NEW(pylist, FD_SETSIZE + 3);
if (rfd2obj == NULL || wfd2obj == NULL || efd2obj == NULL) {
- PyMem_XDEL(rfd2obj);
- PyMem_XDEL(wfd2obj);
- PyMem_XDEL(efd2obj);
+ if (rfd2obj) PyMem_DEL(rfd2obj);
+ if (wfd2obj) PyMem_DEL(wfd2obj);
+ if (efd2obj) PyMem_DEL(efd2obj);
return NULL;
}
#endif
diff --git a/Modules/shamodule.c b/Modules/shamodule.c
index 0504fad..d56e90e 100644
--- a/Modules/shamodule.c
+++ b/Modules/shamodule.c
@@ -380,7 +380,7 @@ staticforward PyTypeObject SHAtype;
static SHAobject *
newSHAobject()
{
- return (SHAobject *)PyObject_NEW(SHAobject, &SHAtype);
+ return (SHAobject *)PyObject_New(SHAobject, &SHAtype);
}
/* Internal methods for a hashing object */
@@ -389,7 +389,7 @@ static void
SHA_dealloc(ptr)
PyObject *ptr;
{
- PyMem_DEL(ptr);
+ PyObject_Del(ptr);
}
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index 939a495..56f1498 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -389,7 +389,7 @@ BUILD_FUNC_DEF_4(PySocketSock_New,int,fd, int,family, int,type, int,proto)
{
PySocketSockObject *s;
PySocketSock_Type.ob_type = &PyType_Type;
- s = PyObject_NEW(PySocketSockObject, &PySocketSock_Type);
+ s = PyObject_New(PySocketSockObject, &PySocketSock_Type);
if (s != NULL) {
s->sock_fd = fd;
s->sock_family = family;
@@ -1368,7 +1368,7 @@ BUILD_FUNC_DEF_1(PySocketSock_dealloc,PySocketSockObject *,s)
{
if (s->sock_fd != -1)
(void) SOCKETCLOSE(s->sock_fd);
- PyMem_DEL(s);
+ PyObject_Del(s);
}
@@ -1948,7 +1948,7 @@ BUILD_FUNC_DEF_3(newSSLObject,
meth=SSLv2_client_method();
#endif
- self = PyObject_NEW(SSLObject, &SSL_Type); /* Create new object */
+ self = PyObject_New(SSLObject, &SSL_Type); /* Create new object */
if (self == NULL){
PyErr_SetObject(SSLErrorObject,
PyString_FromString("newSSLObject error"));
@@ -1962,7 +1962,7 @@ BUILD_FUNC_DEF_3(newSSLObject,
if (self->ctx == NULL) {
PyErr_SetObject(SSLErrorObject,
PyString_FromString("SSL_CTX_new error"));
- PyMem_DEL(self);
+ PyObject_Del(self);
return NULL;
}
@@ -1971,7 +1971,7 @@ BUILD_FUNC_DEF_3(newSSLObject,
PyErr_SetObject(SSLErrorObject,
PyString_FromString(
"Both the key & certificate files must be specified"));
- PyMem_DEL(self);
+ PyObject_Del(self);
return NULL;
}
@@ -1983,7 +1983,7 @@ BUILD_FUNC_DEF_3(newSSLObject,
PyErr_SetObject(SSLErrorObject,
PyString_FromString(
"SSL_CTX_use_PrivateKey_file error"));
- PyMem_DEL(self);
+ PyObject_Del(self);
return NULL;
}
@@ -1993,7 +1993,7 @@ BUILD_FUNC_DEF_3(newSSLObject,
PyErr_SetObject(SSLErrorObject,
PyString_FromString(
"SSL_CTX_use_certificate_chain_file error"));
- PyMem_DEL(self);
+ PyObject_Del(self);
return NULL;
}
}
@@ -2008,7 +2008,7 @@ BUILD_FUNC_DEF_3(newSSLObject,
/* Actually negotiate SSL connection */
PyErr_SetObject(SSLErrorObject,
PyString_FromString("SSL_connect error"));
- PyMem_DEL(self);
+ PyObject_Del(self);
return NULL;
}
self->ssl->debug = 1;
@@ -2079,7 +2079,7 @@ static void SSL_dealloc(SSLObject *self)
SSL_free(self->ssl);
Py_XDECREF(self->x_attr);
Py_XDECREF(self->Socket);
- PyMem_DEL(self);
+ PyObject_Del(self);
}
static PyObject *SSL_getattr(SSLObject *self, char *name)
diff --git a/Modules/stropmodule.c b/Modules/stropmodule.c
index 4c9ee76..2e243a4 100644
--- a/Modules/stropmodule.c
+++ b/Modules/stropmodule.c
@@ -1152,7 +1152,7 @@ static char *mymemreplace(str, len, pat, pat_len, sub, sub_len, count, out_len)
goto return_same;
new_len = len + nfound*(sub_len - pat_len);
- new_s = (char *)malloc(new_len);
+ new_s = (char *)PyMem_MALLOC(new_len);
if (new_s == NULL) return NULL;
*out_len = new_len;
@@ -1225,7 +1225,7 @@ strop_replace(self, args)
}
else {
new = PyString_FromStringAndSize(new_s, out_len);
- free(new_s);
+ PyMem_FREE(new_s);
}
return new;
}
diff --git a/Modules/sunaudiodev.c b/Modules/sunaudiodev.c
index 71c152e..f7b9426 100644
--- a/Modules/sunaudiodev.c
+++ b/Modules/sunaudiodev.c
@@ -139,7 +139,7 @@ newsadobject(arg)
PyMem_DEL(ctldev);
/* Create and initialize the object */
- xp = PyObject_NEW(sadobject, &Sadtype);
+ xp = PyObject_New(sadobject, &Sadtype);
if (xp == NULL) {
close(fd);
return NULL;
@@ -158,7 +158,7 @@ sad_dealloc(xp)
sadobject *xp;
{
close(xp->x_fd);
- PyMem_DEL(xp);
+ PyObject_Del(xp);
}
static PyObject *
@@ -412,7 +412,7 @@ sad_getattr(xp, name)
static sadstatusobject *
sads_alloc() {
- return PyObject_NEW(sadstatusobject, &Sadstatustype);
+ return PyObject_New(sadstatusobject, &Sadstatustype);
}
static void
diff --git a/Modules/svmodule.c b/Modules/svmodule.c
index 75f2023..99c6fa1 100644
--- a/Modules/svmodule.c
+++ b/Modules/svmodule.c
@@ -340,7 +340,7 @@ capture_dealloc(self)
Py_DECREF(self->ob_svideo);
self->ob_svideo = NULL;
}
- PyMem_DEL(self);
+ PyObject_Del(self);
}
static PyObject *
@@ -374,7 +374,7 @@ newcaptureobject(self, ptr, mustunlock)
{
captureobject *p;
- p = PyObject_NEW(captureobject, &Capturetype);
+ p = PyObject_New(captureobject, &Capturetype);
if (p == NULL)
return NULL;
p->ob_svideo = self;
@@ -994,7 +994,7 @@ svideo_dealloc(self)
{
if (self->ob_svideo != NULL)
(void) svCloseVideo(self->ob_svideo);
- PyMem_DEL(self);
+ PyObject_Del(self);
}
static PyObject *
@@ -1026,7 +1026,7 @@ newsvobject(svp)
{
svobject *p;
- p = PyObject_NEW(svobject, &Svtype);
+ p = PyObject_New(svobject, &Svtype);
if (p == NULL)
return NULL;
p->ob_svideo = svp;
diff --git a/Modules/threadmodule.c b/Modules/threadmodule.c
index cb463d9..195a164 100644
--- a/Modules/threadmodule.c
+++ b/Modules/threadmodule.c
@@ -58,12 +58,12 @@ static lockobject *
newlockobject()
{
lockobject *self;
- self = PyObject_NEW(lockobject, &Locktype);
+ self = PyObject_New(lockobject, &Locktype);
if (self == NULL)
return NULL;
self->lock_lock = PyThread_allocate_lock();
if (self->lock_lock == NULL) {
- PyMem_DEL(self);
+ PyObject_Del(self);
self = NULL;
PyErr_SetString(ThreadError, "can't allocate lock");
}
@@ -79,7 +79,7 @@ lock_dealloc(self)
PyThread_release_lock(self->lock_lock);
PyThread_free_lock(self->lock_lock);
- PyMem_DEL(self);
+ PyObject_Del(self);
}
static PyObject *
diff --git a/Modules/xxmodule.c b/Modules/xxmodule.c
index c0d05f4..90a5029 100644
--- a/Modules/xxmodule.c
+++ b/Modules/xxmodule.c
@@ -62,7 +62,7 @@ newXxoObject(arg)
PyObject *arg;
{
XxoObject *self;
- self = PyObject_NEW(XxoObject, &Xxo_Type);
+ self = PyObject_New(XxoObject, &Xxo_Type);
if (self == NULL)
return NULL;
self->x_attr = NULL;
@@ -76,7 +76,7 @@ Xxo_dealloc(self)
XxoObject *self;
{
Py_XDECREF(self->x_attr);
- PyMem_DEL(self);
+ PyObject_Del(self);
}
static PyObject *
diff --git a/Modules/zlibmodule.c b/Modules/zlibmodule.c
index 810ffef..cff7293 100644
--- a/Modules/zlibmodule.c
+++ b/Modules/zlibmodule.c
@@ -46,7 +46,7 @@ newcompobject(type)
PyTypeObject *type;
{
compobject *self;
- self = PyObject_NEW(compobject, type);
+ self = PyObject_New(compobject, type);
if (self == NULL)
return NULL;
self->is_initialised = 0;
@@ -369,7 +369,7 @@ Comp_dealloc(self)
if (self->is_initialised)
deflateEnd(&self->zst);
Py_XDECREF(self->unused_data);
- PyMem_DEL(self);
+ PyObject_Del(self);
}
static void
@@ -378,7 +378,7 @@ Decomp_dealloc(self)
{
inflateEnd(&self->zst);
Py_XDECREF(self->unused_data);
- PyMem_DEL(self);
+ PyObject_Del(self);
}
static char comp_compress__doc__[] =