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.
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.
No, but it's highly likely it would work if your previously malloced memory was page-aligned. Of course malloc-related calls will get cranky later when they discover you've moved their data. Results could include heap invalidation, data corruption, and segmentation faults.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.