Sometimes, we need to operate on memory in a way that is not conventional or, so to speak, not common. As we've seen, memory is allocated with new and released with delete (or, even better, with make_unique and make_shared). There might be cases in which we need to skip some layer—that is, using a Linux system call; for the sake of performance; or because of a custom behavior that we cannot map with the C++ standard library. This is the case with the mmap Linux system call (man 2 mmap). mmap is a POSIX-compliant system call that allows the programmer to map a file to a portion of memory. Among other things, mmap also allows memory to be allocated, and this recipe will teach you how to do it.
Germany
Slovakia
Canada
Brazil
Singapore
Hungary
Philippines
Mexico
Thailand
Ukraine
Luxembourg
Estonia
Lithuania
Norway
Chile
United States
Great Britain
India
Spain
South Korea
Ecuador
Colombia
Taiwan
Switzerland
Indonesia
Cyprus
Denmark
Finland
Poland
Malta
Czechia
New Zealand
Austria
Turkey
France
Sweden
Italy
Egypt
Belgium
Portugal
Slovenia
Ireland
Romania
Greece
Argentina
Malaysia
South Africa
Netherlands
Bulgaria
Latvia
Australia
Japan
Russia