Alignment padding inserts a pseudo block header in front of the allocation,
sets its size field to the pad size and then ORs in 1, which is equivalent
to marking it as a free block, so that xfree() can distinguish it from a
real block header.
This patch simply replaces the magic '1' with the defined 'FREE_BLOCK' to
make it more obvious what's going on. Also, whilst in the neighbourhood,
it removes a stray space after a cast.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
char *q = (char *)p + pad;
struct bhdr *b = (struct bhdr *)(q - BHDR_OVERHEAD);
ASSERT(q > (char *)p);
- b->size = pad | 1;
+ b->size = pad | FREE_BLOCK;
p = q;
}
}
/* Strip alignment padding. */
- b = (struct bhdr *)((char *) p - BHDR_OVERHEAD);
- if ( b->size & 1 )
+ b = (struct bhdr *)((char *)p - BHDR_OVERHEAD);
+ if ( b->size & FREE_BLOCK )
{
- p = (char *)p - (b->size & ~1u);
+ p = (char *)p - (b->size & ~FREE_BLOCK);
b = (struct bhdr *)((char *)p - BHDR_OVERHEAD);
- ASSERT(!(b->size & 1));
+ ASSERT(!(b->size & FREE_BLOCK));
}
xmem_pool_free(p, xenpool);