]> code.delx.au - gnu-emacs/blobdiff - src/gmalloc.c
(syms_of_frame): Fix the example in the doc string.
[gnu-emacs] / src / gmalloc.c
index 77fb31971018a5ea67fe87224ed9ba8e25df9588..eae83a74eb6944c96354015895caf0e151ef4487 100644 (file)
@@ -352,6 +352,10 @@ Cambridge, MA 02139, USA.
 #include <errno.h>
 
 /* How to really get more memory.  */
+#if defined(CYGWIN)
+extern __ptr_t bss_sbrk PP ((ptrdiff_t __size));
+extern int bss_sbrk_did_unexec;
+#endif
 __ptr_t (*__morecore) PP ((ptrdiff_t __size)) = __default_morecore;
 
 /* Debugging hook for `malloc'.  */
@@ -420,7 +424,7 @@ protect_malloc_state (protect_p)
 
   last_state_size = _heaplimit * sizeof *_heapinfo;
   last_heapinfo   = _heapinfo;
-  
+
   if (protect_p != state_protected_p)
     {
       state_protected_p = protect_p;
@@ -992,7 +996,7 @@ _free_internal (ptr)
     return;
 
   PROTECT_MALLOC_STATE (0);
-  
+
   for (l = _aligned_blocks; l != NULL; l = l->next)
     if (l->aligned == ptr)
       {
@@ -1214,7 +1218,7 @@ _free_internal (ptr)
        }
       break;
     }
-  
+
   PROTECT_MALLOC_STATE (1);
 }
 
@@ -1380,7 +1384,7 @@ _realloc_internal (ptr, size)
   block = BLOCK (ptr);
 
   PROTECT_MALLOC_STATE (0);
-  
+
   type = _heapinfo[block].busy.type;
   switch (type)
     {
@@ -1572,7 +1576,14 @@ __ptr_t
 __default_morecore (increment)
      __malloc_ptrdiff_t increment;
 {
-  __ptr_t result = (__ptr_t) __sbrk (increment);
+  __ptr_t result;
+#if defined(CYGWIN)
+  if (!bss_sbrk_did_unexec)
+    {
+      return bss_sbrk (increment);
+    }
+#endif
+  result = (__ptr_t) __sbrk (increment);
   if (result == (__ptr_t) -1)
     return NULL;
   return result;
@@ -1843,7 +1854,7 @@ freehook (ptr)
      __ptr_t ptr;
 {
   struct hdr *hdr;
-    
+
   if (ptr)
     {
       hdr = ((struct hdr *) ptr) - 1;
@@ -1853,7 +1864,7 @@ freehook (ptr)
     }
   else
     hdr = NULL;
-  
+
   __free_hook = old_free_hook;
   free (hdr);
   __free_hook = freehook;
@@ -1887,7 +1898,7 @@ reallochook (ptr, size)
 {
   struct hdr *hdr = NULL;
   __malloc_size_t osize = 0;
-    
+
   if (ptr)
     {
       hdr = ((struct hdr *) ptr) - 1;
@@ -1897,7 +1908,7 @@ reallochook (ptr, size)
       if (size < osize)
        flood ((char *) ptr + size, FREEFLOOD, osize - size);
     }
-  
+
   __free_hook = old_free_hook;
   __malloc_hook = old_malloc_hook;
   __realloc_hook = old_realloc_hook;
@@ -1978,3 +1989,6 @@ mprobe (__ptr_t ptr)
 }
 
 #endif /* GC_MCHECK */
+
+/* arch-tag: 93dce5c0-f49a-41b5-86b1-f91c4169c02e
+   (do not change this comment) */