… | |
… | |
114 | |
114 | |
115 | if (!size) |
115 | if (!size) |
116 | return 0; |
116 | return 0; |
117 | |
117 | |
118 | #ifdef _WIN32 |
118 | #ifdef _WIN32 |
|
|
119 | { |
119 | HANDLE handle = CreateFileMapping (0, 0, PAGE_READWRITE, 0, size, NULL); |
120 | HANDLE handle = CreateFileMapping (0, 0, PAGE_READWRITE, 0, size, NULL); |
120 | |
121 | |
121 | addr = 0; |
122 | addr = 0; |
122 | if (handle) |
123 | if (handle) |
123 | { |
124 | { |
124 | addr = MapViewOfFile (handle, FILE_MAP_WRITE, 0, 0, size); |
125 | addr = MapViewOfFile (handle, FILE_MAP_WRITE, 0, 0, size); |
125 | CloseHandle (handle); |
126 | CloseHandle (handle); |
126 | } |
127 | } |
|
|
128 | } |
127 | #elif defined (MAP_ANONYMOUS) |
129 | #elif defined (MAP_ANONYMOUS) |
128 | addr = mmap (0, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0); |
130 | addr = mmap (0, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0); |
129 | |
131 | |
130 | if (addr == (void *)-1) |
132 | if (addr == (void *)-1) |
131 | addr = 0; |
133 | addr = 0; |