You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

13 lines
254 B

#include <stdint.h>
void* align_after(void* address, int align) {
uintptr_t addr = (uintptr_t) address;
uintptr_t offset = addr % align;
if (offset == 0) {
return address;
} else {
return (void*) (addr + align - align % offset);
}
}