* 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.
This commit is contained in:
Christopher Faylor 2000-07-15 04:36:10 +00:00
parent 2eb392bd77
commit 92e30b7535
2 changed files with 23 additions and 7 deletions

View File

@ -1,3 +1,10 @@
Sat Jul 15 00:32:41 2000 Christopher Faylor <cgf@cygnus.com>
* 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.
Fri Jul 14 22:40:22 2000 Christopher Faylor <cgf@cygnus.com>
* hinfo.cc (hinfo::linearize_fd_array): Make max_used_fd an int so that

View File

@ -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);
}
}