Q:

Does mremap work with malloc?

Is
void * mremap(void *old_address, size_t old_size , size_t new_size, unsigned long flags);

compatible with malloc()?
GCC (C++) and using Linux.
Thanks.

A:

No, it is not. Apart from the fact that malloc doesn't need to give you an address at a page border (which is what mremap expects), it would be dangerous to mess with memory mappings from malloc without malloc knowing you did it. Use realloc instead.

