Mailing List Archive

CVS: python/dist/src/Objects obmalloc.c,2.16,2.17
Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv10662/python/Objects

Modified Files:
obmalloc.c
Log Message:
Changed the #-of-arenas counters to uints -- no need to be insane about
this. But added an overflow check just in case there is.

Got rid of the ushort macro. It wasn't used anymore (it was only used
in the no-longer-exists off_t macro), and there's no plausible use for it.


Index: obmalloc.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/obmalloc.c,v
retrieving revision 2.16
retrieving revision 2.17
diff -C2 -d -r2.16 -r2.17
*** obmalloc.c 30 Mar 2002 07:07:24 -0000 2.16
--- obmalloc.c 30 Mar 2002 10:35:09 -0000 2.17
***************
*** 214,220 ****
#define uchar unsigned char /* assuming == 8 bits */

- #undef ushort
- #define ushort unsigned short /* assuming >= 16 bits */
-
#undef uint
#define uint unsigned int /* assuming >= 16 bits */
--- 214,217 ----
***************
*** 236,240 ****
struct pool_header *nextpool; /* next pool of this size class */
struct pool_header *prevpool; /* previous pool "" */
! ulong arenaindex; /* index into arenas of base adr */
uint szidx; /* block size class index */
uint capacity; /* pool capacity in # of blocks */
--- 233,237 ----
struct pool_header *nextpool; /* next pool of this size class */
struct pool_header *prevpool; /* previous pool "" */
! uint arenaindex; /* index into arenas of base adr */
uint szidx; /* block size class index */
uint capacity; /* pool capacity in # of blocks */
***************
*** 313,318 ****
*/
static uptr *arenas = NULL;
! static ulong narenas = 0;
! static ulong maxarenas = 0;

/* Number of pools still available to be allocated in the current arena. */
--- 310,315 ----
*/
static uptr *arenas = NULL;
! static uint narenas = 0;
! static uint maxarenas = 0;

/* Number of pools still available to be allocated in the current arena. */
***************
*** 331,335 ****
if (ptr)
printf("inserted new arena at %08x\n", ptr);
! printf("# arenas %d\n", narenas);
printf("was mine %lu wasn't mine %lu\n", wasmine, wasntmine);
}
--- 328,332 ----
if (ptr)
printf("inserted new arena at %08x\n", ptr);
! printf("# arenas %u\n", narenas);
printf("was mine %lu wasn't mine %lu\n", wasmine, wasntmine);
}
***************
*** 404,409 ****
*/
uptr *oldarenas;
! int newmax = maxarenas + (maxarenas >> 1);
! uptr *p = (uptr *)PyMem_MALLOC(newmax * sizeof(*arenas));
if (p == NULL)
goto error;
--- 401,410 ----
*/
uptr *oldarenas;
! uptr *p;
! uint newmax = maxarenas + (maxarenas >> 1);
!
! if (newmax <= maxarenas) /* overflow */
! goto error;
! p = (uptr *)PyMem_MALLOC(newmax * sizeof(*arenas));
if (p == NULL)
goto error;
***************
*** 418,422 ****
assert(narenas < maxarenas);
arenas[narenas] = (uptr)bp;
! ++narenas;
dumpem(bp);
return bp;
--- 419,423 ----
assert(narenas < maxarenas);
arenas[narenas] = (uptr)bp;
! ++narenas; /* can't overflow, since narenas < maxarenas before */
dumpem(bp);
return bp;