Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

49. Memory Mappings > Remapping a Mapped Region: mremap()

Remapping a Mapped Region: mremap()

On most UNIX implementations, once a mapping has been created, its location and size can’t be changed. However, Linux provides the (nonportable) mremap() system call, which permits such changes.

#define _GNU_SOURCE
#include <sys/mman.h>

void *mremap(void *old_address, size_t old_size, size_t new_size,
 int flags, ...);

Note

Returns starting address of remapped region on success, or MAP_FAILED on error

The old_address and old_size arguments specify the location and size of an existing mapping that we wish to expand or shrink. The address specified in old_address must be page-aligned, and is normally a value returned by a previous call to mmap(). The desired new size of the mapping is specified in new_size. The values specified in old_size and new_size are both rounded up to the next multiple of the system page size.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint