diff options
author | Christopher Faylor <me@cgf.cx> | 2002-08-07 01:20:59 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2002-08-07 01:20:59 +0000 |
commit | 772f6c3e12a207c923d25fbc04757f01a31fda48 (patch) | |
tree | d4d28111c3be580ccc08770026367fbf06968aca | |
parent | e851d2fe43cebc6028959f9bcb0e457f88e115da (diff) | |
download | cygnal-772f6c3e12a207c923d25fbc04757f01a31fda48.tar.gz cygnal-772f6c3e12a207c923d25fbc04757f01a31fda48.tar.bz2 cygnal-772f6c3e12a207c923d25fbc04757f01a31fda48.zip |
* cygheap.cc (_csbrk): Avoid !cygheap considerations.
(cygheap_init): Deal with unintialized cygheap issues here.
-rw-r--r-- | winsup/cygwin/ChangeLog | 5 | ||||
-rw-r--r-- | winsup/cygwin/cygheap.cc | 33 |
2 files changed, 18 insertions, 20 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 4d6a7238b..93ead8c54 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,4 +1,9 @@ 2002-08-06 Christopher Faylor <cgf@redhat.com> + + * cygheap.cc (_csbrk): Avoid !cygheap considerations. + (cygheap_init): Deal with unintialized cygheap issues here. + +2002-08-06 Christopher Faylor <cgf@redhat.com> Conrad Scott <conrad.scott@dsl.pipex.com * cygheap.cc (_csbrk): Allocate some slop initially. Don't erroneously diff --git a/winsup/cygwin/cygheap.cc b/winsup/cygwin/cygheap.cc index 976618bf7..fb13fbed6 100644 --- a/winsup/cygwin/cygheap.cc +++ b/winsup/cygwin/cygheap.cc @@ -171,25 +171,13 @@ cygheap_fixup_in_child (bool execed) static void *__stdcall _csbrk (int sbs) { - void *prebrk; - - if (!cygheap) - { - init_cheap (); - cygheap_max = cygheap; - (void) _csbrk (sbs + sizeof (*cygheap) + (2 * system_info.dwPageSize)); - prebrk = (char *) (cygheap + 1); - } - else - { - prebrk = cygheap_max; - void *prebrka = pagetrunc (prebrk); - (char *) cygheap_max += sbs; - if (!sbs || (prebrk != prebrka && prebrka == pagetrunc (cygheap_max))) - /* nothing to do */; - else if (!VirtualAlloc (prebrk, (DWORD) sbs, MEM_COMMIT, PAGE_READWRITE)) - api_fatal ("couldn't commit memory for cygwin heap, %E"); - } + void *prebrk = cygheap_max; + void *prebrka = pagetrunc (prebrk); + (char *) cygheap_max += sbs; + if (!sbs || (prebrk != prebrka && prebrka == pagetrunc (cygheap_max))) + /* nothing to do */; + else if (!VirtualAlloc (prebrk, (DWORD) sbs, MEM_COMMIT, PAGE_READWRITE)) + api_fatal ("couldn't commit memory for cygwin heap, %E"); return prebrk; } @@ -198,7 +186,12 @@ extern "C" void __stdcall cygheap_init () { new_muto (cygheap_protect); - _csbrk (0); + if (!cygheap) + { + init_cheap (); + cygheap_max = cygheap; + (void) _csbrk (sizeof (*cygheap)); + } if (!cygheap->fdtab) cygheap->fdtab.init (); } |