@ -167,7 +167,7 @@ static struct memblk *blk_slice(struct list_head *heap, struct memblk *bottom, s
long sys_malloc ( size_t size )
{
void * ptr = kmalloc ( size ) ;
return * ( long * ) & ptr ;
return ( long ) ptr ;
}
void sys_free ( void * ptr )
@ -348,8 +348,8 @@ static struct memblk *blk_try_merge(struct list_head *heap, struct memblk *blk)
}
static struct memblk * blk_merge ( struct list_head * heap ,
struct memblk * bottom ,
struct memblk * top )
struct memblk * bottom ,
struct memblk * top )
{
size_t bottom_size = blk_get_size ( bottom ) ;
size_t top_size = blk_get_size ( top ) ;
@ -368,7 +368,8 @@ static struct memblk *blk_merge(struct list_head *heap,
return bottom ;
}
static struct memblk * blk_slice ( struct list_head * heap , struct memblk * blk , size_t slice_size )
static struct memblk * blk_slice ( struct list_head * heap , struct memblk * blk ,
size_t slice_size )
{
list_delete ( & blk - > list ) ;
@ -412,7 +413,7 @@ static struct memblk *blk_slice(struct list_head *heap, struct memblk *blk, size
return blk ;
}
static inline size_t round_alloc_size_up ( size_t size )
static size_t round_alloc_size_up ( size_t size )
{
size_t rounded = ( size / MIN_SIZE ) * MIN_SIZE ;
if ( rounded < size )
@ -436,7 +437,7 @@ static void blk_set_size(struct memblk *blk, size_t size)
blk - > endsz [ words ] | = size ;
}
static inline void blk_set_alloc ( struct memblk * blk )
static void blk_set_alloc ( struct memblk * blk )
{
size_t words = blk - > size / sizeof ( blk - > size ) ;
@ -444,7 +445,7 @@ static inline void blk_set_alloc(struct memblk *blk)
blk - > endsz [ words ] | = ALLOC_FLAG ;
}
static inline void blk_clear_alloc ( struct memblk * blk )
static void blk_clear_alloc ( struct memblk * blk )
{
size_t words = blk - > size / sizeof ( blk - > size ) ;
@ -472,32 +473,38 @@ static inline int blk_is_border_start(struct memblk *blk)
return blk - > size & BORDER_FLAG ;
}
static inline void blk_set_border_end ( struct memblk * blk )
static void blk_set_border_end ( struct memblk * blk )
{
size_t words = blk - > size / sizeof ( blk - > size ) ;
blk - > endsz [ words ] | = BORDER_FLAG ;
}
static inline void blk_clear_border_end ( struct memblk * blk )
static void blk_clear_border_end ( struct memblk * blk )
{
size_t words = blk - > size / sizeof ( blk - > size ) ;
blk - > endsz [ words ] & = ~ BORDER_FLAG ;
}
static inline int blk_is_border_end ( struct memblk * blk )
static int blk_is_border_end ( struct memblk * blk )
{
size_t words = blk - > size / sizeof ( blk - > size ) ;
return blk - > endsz [ words ] & BORDER_FLAG ;
}
static inline struct memblk * blk_prev ( struct memblk * blk )
static struct memblk * blk_prev ( struct memblk * blk )
{
if ( blk_is_border_start ( blk ) )
return NULL ;
/* gcc does not like accessing index -1 of zero-length arrays */
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Warray-bounds"
# pragma GCC diagnostic ignored "-Wzero-length-bounds"
return ( void * ) blk - ( blk - > prevsz [ - 1 ] & SIZE_MSK ) - OVERHEAD ;
# pragma GCC diagnostic pop
}
static inline struct memblk * blk_next ( struct memblk * blk )
static struct memblk * blk_next ( struct memblk * blk )
{
if ( blk_is_border_end ( blk ) )
return NULL ;