X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Falloc%2Falloc.c;h=e6ed97d2d3910069b471486efa16bdec26206809;hp=28f850dcc7f6ac805c7302c2d9812d95b80b693b;hb=f6d21b50ff672dee48d6bbe4f85bc1efd92fac2c;hpb=dfdebb7ca0d779f76fa6a57cf6c6d7e3c64d8a7f diff --git a/ccan/alloc/alloc.c b/ccan/alloc/alloc.c index 28f850dc..e6ed97d2 100644 --- a/ccan/alloc/alloc.c +++ b/ccan/alloc/alloc.c @@ -275,9 +275,9 @@ static unsigned long align_up(unsigned long x, unsigned long align) return (x + align - 1) & ~(align - 1); } -static void *from_off(struct header *head, unsigned long off) +static struct page_header *from_off(struct header *head, unsigned long off) { - return (char *)head + off; + return (struct page_header *)((char *)head + off); } static unsigned long to_off(struct header *head, void *p) @@ -287,7 +287,7 @@ static unsigned long to_off(struct header *head, void *p) static size_t used_size(unsigned int num_elements) { - return (num_elements + BITS_PER_LONG-1) / BITS_PER_LONG; + return align_up(num_elements, BITS_PER_LONG) / CHAR_BIT; } /*