previous | start | next

Macros

Here are some macro definitions used in mm_malloc, and mm_free to hide these casts and bit operations:

/** Assume:
 * bp points to the allocated/free part of a block
 * p points to a header/footer of a block
 *
 */

#define GET(p)        (*(size_t *)(p))
#define GET_SIZE(p)   (GET(p) & ~0x7)
#define GET_ALLOC(p)  (GET(p) & 0x1)

#define HDRP(bp)      ( (char *)(bp) - 4 )
#define FTRP(bp)      ( (char *)(bp) + GET_SIZE(HDRP(bp)) - 8 )

#define NEXT_BLKP(bp) ( FTRP(bp) + 8 )
#define PREV_BLKP(bp) ( (char *)(bp) - GET_SIZE(HDRP(bp) - 4) )
     


previous | start | next