I'm re-coding the malloc function using brk, sbrk & getpagesize()
I must follow two rules:
1) I must align my memory on a power of 2
It means: If the call to malloc is : malloc(9); i must return them a block of 16 byte. ( the nearest power of 2);
2) I must align the break (program end data segment) on a multiple of 2 pages.
I'm thinking about the rules, i'm wondering if i'm true;
Rule 1) I just need to make the return of my malloc (so the adress returned by malloc in hexa) a multiple of 2 ?
And for the Rule 2)
the break is the last adress in the heap if i'm not wrong, do i need to set my break like this (the break - the heap start) % (2 * getpagesize())== 0? or just the break % (2 * getpagesize() == 0? Thanks