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.
United States
United Kingdom
India
Germany
France
Canada
Russia
Spain
Brazil
Australia
Argentina
Austria
Belgium
Bulgaria
Chile
Colombia
Cyprus
Czechia
Denmark
Ecuador
Egypt
Estonia
Finland
Greece
Hungary
Indonesia
Ireland
Italy
Japan
Latvia
Lithuania
Luxembourg
Malaysia
Malta
Mexico
Netherlands
New Zealand
Norway
Philippines
Poland
Portugal
Romania
Singapore
Slovakia
Slovenia
South Africa
South Korea
Sweden
Switzerland
Taiwan
Thailand
Turkey
Ukraine