(1) it needs to be ALIGNed for both halves of the 'if,' and (2) if you're going to claim that you now have ALIGN(newlen) bytes left, you should have actually allocated ALIGN(newlen), rather than just 'newlen' bytes.