How do I use VirtualAlloc on the Linux platform?

Hello! I somewhat learned how to use VirtualAlloc on Windows, but not sure how to do the same thing on Linux.

I've got the following:
 
memory = (unsigned char*)VirtualAlloc(0, memorySize, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);


I'd love to allocate a chunk of memory on linux as well :(
VirtualAlloc is Windows only.
If you use C then malloc, realloc and free are the normal choices.
If you use C++ you can use new and delete or even better use the STL containers and smart pointers.
Hey Thomas thanks for the quick reply. I'm actually doing a personal learning project and wanted to use an equivalent and avoiding smart pointers.

Is mmap a right choice in that case? I'm not sure how to use it,
> Is mmap a right choice in that case?
Yes, this is the Linux equivalent function.


> I'm not sure how to use it,
Read the manual, scroll down to the example.
https://www.man7.org/linux/man-pages/man2/mmap.2.html
Thanks :)
Topic archived. No new replies allowed.