0

I have code which will be compiled with Win32 and POSIX. With Win32 I use VirtualAlloc, with posix I use mmap(). With Win32 I won't have to remember the size of the allocation for VirtualFree. But mmap reqires a size-argument equal to the size of the allocated region in my case. Currently I'm remembering the size with a size_t-varibable at the beginning of the region. But is it possible to query the size of an mmap()ed allocated region with a pointer to the beginning?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Bonita Montero
  • 2,817
  • 9
  • 22
  • 1
    Possible duplicate of [Why does munmap needs a length as parameter?](https://stackoverflow.com/questions/12076308/why-does-munmap-needs-a-length-as-parameter) – Shloim Apr 02 '19 at 07:58
  • I don't think this is a duplicate because there may be means to query the size of mmap()ed region. – Bonita Montero Apr 02 '19 at 09:05

1 Answers1

0

This is not possible, Linux does not keep a record of individual mmap calls.

Timothy Baldwin
  • 3,551
  • 1
  • 14
  • 23