Revert last patch to xmalloc.c, and instead bring over this patch from
[deliverable/binutils-gdb.git] / libiberty / xmalloc.c
index 7b3d8d4bcc9a0e6741ea4e73aa7db74126bbdc1d..be25c5aca190f201268bf6acea6eb42e99334d43 100644 (file)
@@ -1,5 +1,5 @@
 /* memory allocation routines with error checking.
-   Copyright 1989, 90, 91, 92, 93, 94, 1999 Free Software Foundation, Inc.
+   Copyright 1989, 90, 91, 92, 93, 94 Free Software Foundation, Inc.
    
 This file is part of the libiberty library.
 Libiberty is free software; you can redistribute it and/or
@@ -43,32 +43,22 @@ PTR sbrk PARAMS ((ptrdiff_t));
 /* The program name if set.  */
 static const char *name = "";
 
-#if !defined (__CYGWIN__) && defined (__CYGWIN32__)
-#define __CYGWIN__ 1
-#endif
-
-/* On Unix systems we use sbrk to determine how much memory has been
-   allocated.  */
-#undef USE_SBRK
-#if (! defined (_WIN32) && ! defined (__INTERIX)) || defined (__CYGWIN__) || defined (__UWIN__)
-#define USE_SBRK
-#endif
-
-#ifdef USE_SBRK
+#ifdef HAVE_SBRK
 /* The initial sbrk, set when the program name is set. Not used for win32
    ports other than cygwin32.  */
 static char *first_break = NULL;
-#endif
+#endif /* HAVE_SBRK */
 
 void
 xmalloc_set_program_name (s)
      const char *s;
 {
   name = s;
-#ifdef USE_SBRK
+#ifdef HAVE_SBRK
+  /* Win32 ports other than cygwin32 don't have brk() */
   if (first_break == NULL)
     first_break = (char *) sbrk (0);
-#endif
+#endif /* HAVE_SBRK */
 }
 
 PTR
@@ -82,7 +72,7 @@ xmalloc (size)
   newmem = malloc (size);
   if (!newmem)
     {
-#ifdef USE_SBRK
+#ifdef HAVE_SBRK
       extern char **environ;
       size_t allocated;
 
@@ -94,12 +84,12 @@ xmalloc (size)
               "\n%s%sCan not allocate %lu bytes after allocating %lu bytes\n",
               name, *name ? ": " : "",
               (unsigned long) size, (unsigned long) allocated);
-#else
+#else /* HAVE_SBRK */
       fprintf (stderr,
               "\n%s%sCan not allocate %lu bytes\n",
               name, *name ? ": " : "",
               (unsigned long) size);
-#endif /* ! USE_SBRK */
+#endif /* HAVE_SBRK */
       xexit (1);
     }
   return (newmem);
@@ -117,7 +107,7 @@ xcalloc (nelem, elsize)
   newmem = calloc (nelem, elsize);
   if (!newmem)
     {
-#ifdef USE_SBRK
+#ifdef HAVE_SBRK
       extern char **environ;
       size_t allocated;
 
@@ -129,12 +119,12 @@ xcalloc (nelem, elsize)
               "\n%s%sCan not allocate %lu bytes after allocating %lu bytes\n",
               name, *name ? ": " : "",
               (unsigned long) (nelem * elsize), (unsigned long) allocated);
-#else
+#else /* HAVE_SBRK */
       fprintf (stderr,
               "\n%s%sCan not allocate %lu bytes\n",
               name, *name ? ": " : "",
               (unsigned long) (nelem * elsize));
-#endif /* ! USE_SBRK */
+#endif /* HAVE_SBRK */
       xexit (1);
     }
   return (newmem);
@@ -155,7 +145,7 @@ xrealloc (oldmem, size)
     newmem = realloc (oldmem, size);
   if (!newmem)
     {
-#ifdef USE_SBRK
+#ifdef HAVE_SBRK
       extern char **environ;
       size_t allocated;
 
@@ -167,12 +157,12 @@ xrealloc (oldmem, size)
               "\n%s%sCan not reallocate %lu bytes after allocating %lu bytes\n",
               name, *name ? ": " : "",
               (unsigned long) size, (unsigned long) allocated);
-#else
+#else /* HAVE_SBRK */
       fprintf (stderr,
               "\n%s%sCan not reallocate %lu bytes\n",
               name, *name ? ": " : "",
               (unsigned long) size);
-#endif /* ! USE_SBRK */
+#endif /* HAVE_SBRK */
       xexit (1);
     }
   return (newmem);
This page took 0.023903 seconds and 4 git commands to generate.