diff options
author | Christopher Faylor <me@cgf.cx> | 2000-07-15 04:36:10 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2000-07-15 04:36:10 +0000 |
commit | 92e30b7535407032fd7937a8abccd3180a70fefc (patch) | |
tree | 26b03f756f69335ed97315931a73115aec892325 /winsup/cygwin/dll_init.cc | |
parent | 2eb392bd77de1535823daeae04c83fae0e331ee8 (diff) | |
download | newlib-92e30b7535407032fd7937a8abccd3180a70fefc.zip newlib-92e30b7535407032fd7937a8abccd3180a70fefc.tar.gz newlib-92e30b7535407032fd7937a8abccd3180a70fefc.tar.bz2 |
* dll_init.cc (dll_list::alloc): Round correctly. Use VirtualAlloc since
shared file mapping is unnecessary.
(dll_list::detach): Release memory via VirtualFree since there we no longer use
shared file mapping.
Diffstat (limited to 'winsup/cygwin/dll_init.cc')
-rw-r--r-- | winsup/cygwin/dll_init.cc | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/winsup/cygwin/dll_init.cc b/winsup/cygwin/dll_init.cc index 94cc8e6..924dcc1 100644 --- a/winsup/cygwin/dll_init.cc +++ b/winsup/cygwin/dll_init.cc @@ -132,13 +132,22 @@ dll_list::alloc (HINSTANCE h, per_process *p, dll_type type) /* Need to do the shared memory thing since W95 can't allocate in the shared memory region otherwise. */ - HANDLE h1 = CreateFileMapping (INVALID_HANDLE_VALUE, &sec_none_nih, - PAGE_READWRITE, 0, sizeof (dll), NULL); - DWORD n = (DWORD) m.BaseAddress; - n = ((n - (n % s1.dwAllocationGranularity)) + s1.dwAllocationGranularity); - d = (dll *) MapViewOfFileEx (h1, FILE_MAP_WRITE, 0, 0, 0, (void *) n); - CloseHandle (h1); + DWORD r = n % s1.dwAllocationGranularity; + + if (r) + n = ((n - r) + s1.dwAllocationGranularity); + if (VirtualAlloc ((void *) n, sizeof (dll), MEM_RESERVE, PAGE_READWRITE)) + d = (dll *) VirtualAlloc ((void *) n, sizeof (dll), MEM_COMMIT, PAGE_READWRITE); + + if (d == NULL) + { +#ifdef DEBUGGING + system_printf ("VirtualAlloc failed for %p, %E", n); +#endif + __seterrno (); + return NULL; + } /* Now we've allocated a block of information. Fill it in with the supplied info about this DLL. */ @@ -176,7 +185,7 @@ dll_list::detach (dll *d) loaded_dlls--; if (end == d) end = d->prev; - UnmapViewOfFile (d); + VirtualFree (d, 0, MEM_RELEASE); } } |