Regionlist overhaul: Shrink struct regl

parent 8672597b
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
struct regl { struct regl {
unsigned magic; unsigned magic;
#define REGL_MAGIC 0xe946b3c2 #define REGL_MAGIC 0xe946b3c2
unsigned n, space; uint16_t n, space;
struct buddy_ptr_page alloc; struct buddy_ptr_page alloc;
VSTAILQ_ENTRY(regl) list; VSTAILQ_ENTRY(regl) list;
struct buddy_off_extent arr[]; struct buddy_off_extent arr[];
...@@ -150,8 +150,8 @@ regl_alloc_bits(buddy_t *membuddy, const uint8_t bits, int8_t cram, ...@@ -150,8 +150,8 @@ regl_alloc_bits(buddy_t *membuddy, const uint8_t bits, int8_t cram,
r->magic = REGL_MAGIC; r->magic = REGL_MAGIC;
b = sz / sizeof *r->arr; b = sz / sizeof *r->arr;
assert(b <= UINT_MAX); assert(b <= UINT16_MAX);
r->space = (unsigned)b; r->space = (typeof(r->space))b;
r->alloc = alloc; r->alloc = alloc;
return (r); return (r);
} }
...@@ -222,7 +222,7 @@ regionlist_add(struct regionlist *rl, ...@@ -222,7 +222,7 @@ regionlist_add(struct regionlist *rl,
const struct buddy_off_extent *regs, unsigned n) const struct buddy_off_extent *regs, unsigned n)
{ {
struct regl *regl; struct regl *regl;
unsigned av, nn; uint16_t av, nn;
CHECK_OBJ_NOTNULL(rl, REGIONLIST_MAGIC); CHECK_OBJ_NOTNULL(rl, REGIONLIST_MAGIC);
regl = VSTAILQ_LAST(&rl->head, regl, list); regl = VSTAILQ_LAST(&rl->head, regl, list);
...@@ -240,7 +240,7 @@ regionlist_add(struct regionlist *rl, ...@@ -240,7 +240,7 @@ regionlist_add(struct regionlist *rl,
if (av < n) if (av < n)
nn = av; nn = av;
else else
nn = n; nn = (typeof(nn))n;
memcpy(&regl->arr[regl->n], regs, nn * sizeof *regs); memcpy(&regl->arr[regl->n], regs, nn * sizeof *regs);
regl->n += nn; regl->n += nn;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment