|
From: <sv...@va...> - 2005-07-17 17:20:33
|
Author: njn
Date: 2005-07-17 18:20:30 +0100 (Sun, 17 Jul 2005)
New Revision: 4151
Log:
Replace is_inuse_bszB() with is_inuse_block(), which is higher-level
and thus makes the code that uses it easier to understand.
Modified:
trunk/coregrind/m_mallocfree.c
Modified: trunk/coregrind/m_mallocfree.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_mallocfree.c 2005-07-17 17:12:24 UTC (rev 4150)
+++ trunk/coregrind/m_mallocfree.c 2005-07-17 17:20:30 UTC (rev 4151)
@@ -165,15 +165,6 @@
return bszB & (~SIZE_T_0x1);
}
=20
-// Does this bszB have the in-use attribute?
-static __inline__
-Bool is_inuse_bszB ( SizeT bszB )
-{
- vg_assert(bszB !=3D 0);
- return (0 !=3D (bszB & SIZE_T_0x1)) ? False : True;
-}
-
-
// Set and get the lower size field of a block.
static __inline__
void set_bszB_lo ( Block* b, SizeT bszB )
@@ -186,6 +177,15 @@
return *(SizeT*)&b[0];
}
=20
+// Does this block have the in-use attribute?
+static __inline__
+Bool is_inuse_block ( Block* b )
+{
+ SizeT bszB =3D get_bszB_lo(b);
+ vg_assert(bszB !=3D 0);
+ return (0 !=3D (bszB & SIZE_T_0x1)) ? False : True;
+}
+
// Get the address of the last byte in a block
static __inline__
UByte* last_byte ( Block* b )
@@ -610,7 +610,7 @@
UInt i;
if (get_bszB_lo(b) !=3D get_bszB_hi(b))
{BLEAT("sizes");return False;}
- if (!a->clientmem && is_inuse_bszB(get_bszB_lo(b))) {
+ if (!a->clientmem && is_inuse_block(b)) {
for (i =3D 0; i < a->rz_szB; i++) {
if (get_rz_lo_byte(a, b, i) !=3D=20
(UByte)(((Addr)b&0xff) ^ REDZONE_LO_MASK))
@@ -642,7 +642,7 @@
b =3D (Block*)&sb->payload_bytes[i];
b_bszB =3D get_bszB_lo(b);
VG_(printf)( " block at %d, bszB %d: ", i, mk_plain_bszB(b_bs=
zB) );
- VG_(printf)( "%s, ", is_inuse_bszB(b_bszB) ? "inuse" : "free");
+ VG_(printf)( "%s, ", is_inuse_block(b) ? "inuse" : "free");
VG_(printf)( "%s\n", blockSane(a, b) ? "ok" : "BAD" );
}
vg_assert(i =3D=3D sb->n_payload_bytes); // no overshoot at end =
of Sb
@@ -684,7 +684,7 @@
" BAD\n", sb, i, b_bszB );
BOMB;
}
- thisFree =3D !is_inuse_bszB(b_bszB);
+ thisFree =3D !is_inuse_block(b);
if (thisFree && lastWasFree) {
VG_(printf)("sanity_check_malloc_arena: sb %p, block %d (bsz=
B %d): "
"UNMERGED FREES\n",
@@ -1004,7 +1004,7 @@
if (other_b+min_useful_bszB(a)-1 <=3D (Block*)sb_end) {
// Ok, we have a successor, merge if it's not in use.
other_bszB =3D get_bszB_lo(other_b);
- if (!is_inuse_bszB(other_bszB)) {
+ if (!is_inuse_block(other_b)) {
// VG_(printf)( "merge-successor\n");
other_bszB =3D mk_plain_bszB(other_bszB);
# ifdef DEBUG_MALLOC
@@ -1029,7 +1029,7 @@
// Ok, we have a predecessor, merge if it's not in use.
other_b =3D get_predecessor_block( b );
other_bszB =3D get_bszB_lo(other_b);
- if (!is_inuse_bszB(other_bszB)) {
+ if (!is_inuse_block(other_b)) {
// VG_(printf)( "merge-predecessor\n");
other_bszB =3D mk_plain_bszB(other_bszB);
unlinkBlock( a, b, b_listno );
@@ -1156,7 +1156,7 @@
+ overhead_szB_hi(a) - (UByte*)align_b );
=20
/* Final sanity checks. */
- vg_assert( is_inuse_bszB(get_bszB_lo(get_payload_block(a, align_p))) =
);
+ vg_assert( is_inuse_block(get_payload_block(a, align_p)) );
=20
vg_assert(req_pszB
<=3D=20
@@ -1235,9 +1235,8 @@
b =3D get_payload_block(a, ptr);
vg_assert(blockSane(a, b));
=20
- old_bszB =3D get_bszB_lo(b);
- vg_assert(is_inuse_bszB(old_bszB));
- old_bszB =3D mk_plain_bszB(old_bszB);
+ vg_assert(is_inuse_block(b));
+ old_bszB =3D mk_plain_bszB(get_bszB_lo(b));
old_pszB =3D bszB_to_pszB(a, old_bszB);
=20
if (req_pszB <=3D old_pszB) {
|