|
|
|
@ -53,12 +53,12 @@ struct memblk {
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* overhead per allocation in bytes */
|
|
|
|
|
/* overhead per memory block in bytes (the two block sizes at the beginning and end) */
|
|
|
|
|
#define OVERHEAD (2 * sizeof(usize))
|
|
|
|
|
/* every allocation is padded to a multiple of this */
|
|
|
|
|
#define MIN_SIZE (sizeof(struct clist))
|
|
|
|
|
|
|
|
|
|
/* memory blocks, sorted by increasing low_size */
|
|
|
|
|
/* memory blocks, sorted by increasing size */
|
|
|
|
|
static CLIST(blocks);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
@ -88,9 +88,9 @@ static usize grow_heap(usize num_pages);
|
|
|
|
|
/**
|
|
|
|
|
* @brief Add a new block at the end of the heap by downloading more RAM (`grow_heap()`, actually). */
|
|
|
|
|
static struct memblk *blk_create(usize num_pages);
|
|
|
|
|
/** @brief Get the usable block low_size in bytes, without flags or overhead. */
|
|
|
|
|
/** @brief Get the usable block size in bytes, without flags or overhead. */
|
|
|
|
|
static usize blk_get_size(struct memblk *blk);
|
|
|
|
|
/** @brief Set the usable block low_size without overhead and without affecting flags. */
|
|
|
|
|
/** @brief Set the usable block size without overhead and without affecting flags. */
|
|
|
|
|
static void blk_set_size(struct memblk *blk, usize size);
|
|
|
|
|
/** @brief Flag a block as allocated. */
|
|
|
|
|
static void blk_set_alloc(struct memblk *blk);
|
|
|
|
|