Added retry routine on heap creation until the base address is suitable.
This commit is contained in:
parent
e0b3182786
commit
40f7646e22
2 changed files with 24 additions and 4 deletions
|
@ -28,8 +28,28 @@
|
|||
#ifdef VANILLA_WIN32
|
||||
HANDLE g_heap;
|
||||
|
||||
struct garbage_heap {
|
||||
HANDLE handle;
|
||||
struct garbage_heap *next;
|
||||
};
|
||||
|
||||
# define HEAP_MIN_BASE 0x08000000
|
||||
|
||||
void init_inheritable_heap(void) {
|
||||
g_heap = HeapCreate(0, 0, 0);
|
||||
struct garbage_heap *heaps = NULL;
|
||||
|
||||
while ((void*)(g_heap = HeapCreate(0, 0, 0)) < (void*)HEAP_MIN_BASE) {
|
||||
if (g_heap == NULL)
|
||||
break;
|
||||
|
||||
struct garbage_heap *heap = malloc(sizeof(struct garbage_heap));
|
||||
heap->handle = g_heap;
|
||||
heap->next = heaps;
|
||||
heaps = heap;
|
||||
}
|
||||
for (struct garbage_heap *h = heaps; h != NULL; h = h->next)
|
||||
HeapDestroy(h->handle);
|
||||
|
||||
if (g_heap == (HANDLE) NULL) {
|
||||
fputs("Could not create the private inheritable heap.", stderr);
|
||||
abort();
|
||||
|
|
|
@ -169,8 +169,6 @@ static void CALLBACK handle_child_terminated(PVOID lpParameter,
|
|||
|
||||
int resume_child(void) {
|
||||
#ifdef VANILLA_WIN32
|
||||
init_inheritable_heap();
|
||||
|
||||
TCHAR mapping_name[128];
|
||||
_sntprintf(mapping_name, 128, g_mapping_name, GetCurrentProcessId());
|
||||
|
||||
|
@ -179,8 +177,10 @@ int resume_child(void) {
|
|||
FALSE,
|
||||
mapping_name);
|
||||
|
||||
if (sharedMem == NULL)
|
||||
if (sharedMem == NULL) {
|
||||
init_inheritable_heap();
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct full_context *ctx = (struct full_context *) MapViewOfFile(sharedMem,
|
||||
FILE_MAP_ALL_ACCESS,
|
||||
|
|
Loading…
Add table
Reference in a new issue