c++ - Characteristics of mremap function in Linux -


in linux mremap function used remap memory mapped using mmap. please me clarify following:

  1. if mremap function failed, status of old mapped memory?
  2. if mremap function failed, there need of calling function munmap?
  3. if mremap function succeeded, previous data in remapped memory?

mremap attempts increase allocation in-place, falls allocating new region if cannot increase size of current region.

mremap() expands (or shrinks) existing memory mapping, potentially moving @ same time (controlled flags argument , available virtual address space). src

  1. if mremap fails, old memory fine (just realloc).

  2. if mremap fails, there's nothing munmap (from this call, @ least). see item 1.

  3. if mremap succeeds , has move, old memory copied new (and old 1 munmap'ped you). if mremap able increase size in-place, memory not moved , no new allocation created.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -