[Zodb-checkins] CVS: StandaloneZODB/BTrees - BTreeItemsTemplate.c:1.9 BTreeModuleTemplate.c:1.21 BTreeTemplate.c:1.25 BucketTemplate.c:1.28
Jeremy Hylton
jeremy@zope.com
Fri, 8 Mar 2002 13:33:05 -0500
Update of /cvs-repository/StandaloneZODB/BTrees
In directory cvs.zope.org:/tmp/cvs-serv25780
Modified Files:
BTreeItemsTemplate.c BTreeModuleTemplate.c BTreeTemplate.c
BucketTemplate.c
Log Message:
(Possibly) correct use of Python memory APIs.
Fix SF bug #516768 reported by Dave Wallace.
Replace use of PyMem_DEL() with PyObject_Del() on object dealloc
functions. The use of PyMem_DEL() is incorrect for object
deallocation, because it only ever calls the low-level free(). If a
custom allocator like pymalloc is used, it needs to be called to free
the memory.
Also replace bare malloc() and realloc() with PyMem_Malloc() and
PyMem_Realloc(). I think this isn't a strict bug fix, but a would be
nice. It guarantees that BTrees objects get their memory from the
same allocator as the Python core.
=== StandaloneZODB/BTrees/BTreeItemsTemplate.c 1.8 => 1.9 ===
Py_XDECREF(self->lastbucket);
Py_XDECREF(self->currentbucket);
- PyMem_DEL(self);
+ PyObject_DEL(self);
}
static int
=== StandaloneZODB/BTrees/BTreeModuleTemplate.c 1.20 => 1.21 ===
ASSERT(sz > 0, "non-positive size malloc", NULL);
- if ((r=malloc(sz))) return r;
+ if ((r=PyMem_Malloc(sz))) return r;
PyErr_NoMemory();
return NULL;
@@ -224,8 +224,8 @@
ASSERT(sz > 0, "non-positive size realloc", NULL);
- if (p) r=realloc(p,sz);
- else r=malloc(sz);
+ if (p) r=PyMem_Realloc(p,sz);
+ else r=PyMem_Malloc(sz);
UNLESS (r) PyErr_NoMemory();
=== StandaloneZODB/BTrees/BTreeTemplate.c 1.24 => 1.25 ===
Py_DECREF(self->ob_type);
- PyMem_DEL(self);
+ PyObject_Del(self);
}
static int
=== StandaloneZODB/BTrees/BucketTemplate.c 1.27 => 1.28 ===
Py_DECREF(self->ob_type);
- PyMem_DEL(self);
+ PyObject_Del(self);
}
/* Code to access Bucket objects as mappings */