[Python-checkins] CVS: python/dist/src/Objects obmalloc.c,2.8,2.9
Tim Peters
tim_one@users.sourceforge.net
Sat, 23 Mar 2002 14:28:20 -0800
Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv27491/python/Objects
Modified Files:
obmalloc.c
Log Message:
Minor code cleanup -- no semantic changes.
Index: obmalloc.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/obmalloc.c,v
retrieving revision 2.8
retrieving revision 2.9
diff -C2 -d -r2.8 -r2.9
*** obmalloc.c 23 Mar 2002 10:03:50 -0000 2.8
--- obmalloc.c 23 Mar 2002 22:28:18 -0000 2.9
***************
*** 628,631 ****
--- 628,632 ----
/*==========================================================================*/
/* pymalloc not enabled: Redirect the entry points to the PyMem family. */
+
void *
_PyMalloc_Malloc(size_t n)
***************
*** 647,650 ****
--- 648,656 ----
#endif /* WITH_PYMALLOC */
+ /*==========================================================================*/
+ /* Regardless of whether pymalloc is enabled, export entry points for
+ * the object-oriented pymalloc functions.
+ */
+
PyObject *
_PyMalloc_New(PyTypeObject *tp)
***************
*** 676,680 ****
#ifdef PYMALLOC_DEBUG
/*==========================================================================*/
! /* A x-platform debugging allocator. */
#define PYMALLOC_CLEANBYTE 0xCB /* uninitialized memory */
--- 682,688 ----
#ifdef PYMALLOC_DEBUG
/*==========================================================================*/
! /* A x-platform debugging allocator. This doesn't manage memory directly,
! * it wraps a real allocator, adding extra debugging info to the memory blocks.
! */
#define PYMALLOC_CLEANBYTE 0xCB /* uninitialized memory */
***************
*** 688,692 ****
read4(const void *p)
{
! const unsigned char *q = (unsigned char *)p;
return ((ulong)q[0] << 24) |
((ulong)q[1] << 16) |
--- 696,700 ----
read4(const void *p)
{
! const uchar *q = (const uchar *)p;
return ((ulong)q[0] << 24) |
((ulong)q[1] << 16) |
***************
*** 700,708 ****
write4(void *p, ulong n)
{
! unsigned char *q = (unsigned char *)p;
! q[0] = (unsigned char)((n >> 24) & 0xff);
! q[1] = (unsigned char)((n >> 16) & 0xff);
! q[2] = (unsigned char)((n >> 8) & 0xff);
! q[3] = (unsigned char)( n & 0xff);
}
--- 708,716 ----
write4(void *p, ulong n)
{
! uchar *q = (uchar *)p;
! q[0] = (uchar)((n >> 24) & 0xff);
! q[1] = (uchar)((n >> 16) & 0xff);
! q[2] = (uchar)((n >> 8) & 0xff);
! q[3] = (uchar)( n & 0xff);
}
***************
*** 759,763 ****
{
uchar *p; /* base address of malloc'ed block */
! uchar *q; /* p + 8 + nbytes + */
size_t total; /* nbytes + 16 */
--- 767,771 ----
{
uchar *p; /* base address of malloc'ed block */
! uchar *tail; /* p + 8 + nbytes == pointer to tail pad bytes */
size_t total; /* nbytes + 16 */
***************
*** 786,800 ****
memset(p+8, PYMALLOC_CLEANBYTE, nbytes);
! q = p + 8 + nbytes;
! q[0] = q[1] = q[2] = q[3] = PYMALLOC_FORBIDDENBYTE;
! write4(q+4, serialno);
return p+8;
}
! /* The debug free first uses the address to find the number of bytes
! originally asked for, then checks the 8 bytes on each end for
! sanity (in particular, that the PYMALLOC_FORBIDDENBYTEs are still
! intact).
Then fills the original bytes with PYMALLOC_DEADBYTE.
Then calls the underlying free.
--- 794,806 ----
memset(p+8, PYMALLOC_CLEANBYTE, nbytes);
! tail = p + 8 + nbytes;
! tail[0] = tail[1] = tail[2] = tail[3] = PYMALLOC_FORBIDDENBYTE;
! write4(tail + 4, serialno);
return p+8;
}
! /* The debug free first checks the 8 bytes on each end for sanity (in
! particular, that the PYMALLOC_FORBIDDENBYTEs are still intact).
Then fills the original bytes with PYMALLOC_DEADBYTE.
Then calls the underlying free.
***************
*** 803,807 ****
_PyMalloc_DebugFree(void *p, int family)
{
! uchar *q = (uchar*)p;
size_t nbytes;
--- 809,813 ----
_PyMalloc_DebugFree(void *p, int family)
{
! uchar *q = (uchar *)p;
size_t nbytes;
***************
*** 915,923 ****
the serial number (the address deref could blow up). */
! fprintf(stderr, " the 3 pad bytes at p-3 are ");
if (*(q-3) == PYMALLOC_FORBIDDENBYTE &&
*(q-2) == PYMALLOC_FORBIDDENBYTE &&
*(q-1) == PYMALLOC_FORBIDDENBYTE) {
! fprintf(stderr, "PYMALLOC_FORBIDDENBYTE, as expected\n");
}
else {
--- 921,929 ----
the serial number (the address deref could blow up). */
! fputs(" the 3 pad bytes at p-3 are ", stderr);
if (*(q-3) == PYMALLOC_FORBIDDENBYTE &&
*(q-2) == PYMALLOC_FORBIDDENBYTE &&
*(q-1) == PYMALLOC_FORBIDDENBYTE) {
! fputs("PYMALLOC_FORBIDDENBYTE, as expected\n", stderr);
}
else {
***************
*** 940,944 ****
tail[2] == PYMALLOC_FORBIDDENBYTE &&
tail[3] == PYMALLOC_FORBIDDENBYTE) {
! fprintf(stderr, "PYMALLOC_FORBIDDENBYTE, as expected\n");
}
else {
--- 946,950 ----
tail[2] == PYMALLOC_FORBIDDENBYTE &&
tail[3] == PYMALLOC_FORBIDDENBYTE) {
! fputs("PYMALLOC_FORBIDDENBYTE, as expected\n", stderr);
}
else {
***************
*** 962,966 ****
if (nbytes > 0) {
int i = 0;
! fprintf(stderr, " data at p:");
/* print up to 8 bytes at the start */
while (q < tail && i < 8) {
--- 968,972 ----
if (nbytes > 0) {
int i = 0;
! fputs(" data at p:", stderr);
/* print up to 8 bytes at the start */
while (q < tail && i < 8) {
***************
*** 972,976 ****
if (q < tail) {
if (tail - q > 8) {
! fprintf(stderr, " ...");
q = tail - 8;
}
--- 978,982 ----
if (q < tail) {
if (tail - q > 8) {
! fputs(" ...", stderr);
q = tail - 8;
}
***************
*** 980,984 ****
}
}
! fprintf(stderr, "\n");
}
}
--- 986,990 ----
}
}
! fputc('\n', stderr);
}
}