gnats-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Changes to gnats/libiberty/xmalloc.c


From: Milan Zamazal
Subject: Changes to gnats/libiberty/xmalloc.c
Date: Mon, 10 Dec 2001 18:04:35 -0500

Index: gnats/libiberty/xmalloc.c
diff -c gnats/libiberty/xmalloc.c:1.2 gnats/libiberty/xmalloc.c:1.3
*** gnats/libiberty/xmalloc.c:1.2       Tue Oct 26 03:10:16 1999
--- gnats/libiberty/xmalloc.c   Mon Dec 10 18:03:26 2001
***************
*** 17,22 ****
--- 17,25 ----
  not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  Boston, MA 02111-1307, USA.  */
  
+ #ifdef HAVE_CONFIG_H
+ #include "config.h"
+ #endif
  #include "ansidecl.h"
  #include "libiberty.h"
  
***************
*** 61,66 ****
--- 64,94 ----
  #endif /* HAVE_SBRK */
  }
  
+ void
+ xmalloc_failed (size)
+      size_t size;
+ {
+ #ifdef HAVE_SBRK
+   extern char **environ;
+   size_t allocated;
+ 
+   if (first_break != NULL)
+     allocated = (char *) sbrk (0) - first_break;
+   else
+     allocated = (char *) sbrk (0) - (char *) &environ;
+   fprintf (stderr,
+          "\n%s%sCannot allocate %lu bytes after allocating %lu bytes\n",
+          name, *name ? ": " : "",
+          (unsigned long) size, (unsigned long) allocated);
+ #else /* HAVE_SBRK */
+   fprintf (stderr,
+          "\n%s%sCannot allocate %lu bytes\n",
+          name, *name ? ": " : "",
+          (unsigned long) size);
+ #endif /* HAVE_SBRK */
+   xexit (1);
+ }  
+ 
  PTR
  xmalloc (size)
      size_t size;
***************
*** 71,97 ****
      size = 1;
    newmem = malloc (size);
    if (!newmem)
!     {
! #ifdef HAVE_SBRK
!       extern char **environ;
!       size_t allocated;
  
-       if (first_break != NULL)
-       allocated = (char *) sbrk (0) - first_break;
-       else
-       allocated = (char *) sbrk (0) - (char *) &environ;
-       fprintf (stderr,
-              "\n%s%sCan not allocate %lu bytes after allocating %lu bytes\n",
-              name, *name ? ": " : "",
-              (unsigned long) size, (unsigned long) allocated);
- #else /* HAVE_SBRK */
-       fprintf (stderr,
-               "\n%s%sCan not allocate %lu bytes\n",
-               name, *name ? ": " : "",
-               (unsigned long) size);
- #endif /* HAVE_SBRK */
-       xexit (1);
-     }
    return (newmem);
  }
  
--- 99,106 ----
      size = 1;
    newmem = malloc (size);
    if (!newmem)
!     xmalloc_failed (size);
  
    return (newmem);
  }
  
***************
*** 106,132 ****
  
    newmem = calloc (nelem, elsize);
    if (!newmem)
!     {
! #ifdef HAVE_SBRK
!       extern char **environ;
!       size_t allocated;
  
-       if (first_break != NULL)
-       allocated = (char *) sbrk (0) - first_break;
-       else
-       allocated = (char *) sbrk (0) - (char *) &environ;
-       fprintf (stderr,
-              "\n%s%sCan not allocate %lu bytes after allocating %lu bytes\n",
-              name, *name ? ": " : "",
-              (unsigned long) (nelem * elsize), (unsigned long) allocated);
- #else /* HAVE_SBRK */
-       fprintf (stderr,
-               "\n%s%sCan not allocate %lu bytes\n",
-               name, *name ? ": " : "",
-               (unsigned long) (nelem * elsize));
- #endif /* HAVE_SBRK */
-       xexit (1);
-     }
    return (newmem);
  }
  
--- 115,122 ----
  
    newmem = calloc (nelem, elsize);
    if (!newmem)
!     xmalloc_failed (nelem * elsize);
  
    return (newmem);
  }
  
***************
*** 144,169 ****
    else
      newmem = realloc (oldmem, size);
    if (!newmem)
!     {
! #ifdef HAVE_SBRK
!       extern char **environ;
!       size_t allocated;
  
-       if (first_break != NULL)
-       allocated = (char *) sbrk (0) - first_break;
-       else
-       allocated = (char *) sbrk (0) - (char *) &environ;
-       fprintf (stderr,
-              "\n%s%sCan not reallocate %lu bytes after allocating %lu 
bytes\n",
-              name, *name ? ": " : "",
-              (unsigned long) size, (unsigned long) allocated);
- #else /* HAVE_SBRK */
-       fprintf (stderr,
-               "\n%s%sCan not reallocate %lu bytes\n",
-               name, *name ? ": " : "",
-               (unsigned long) size);
- #endif /* HAVE_SBRK */
-       xexit (1);
-     }
    return (newmem);
  }
--- 134,140 ----
    else
      newmem = realloc (oldmem, size);
    if (!newmem)
!     xmalloc_failed (size);
  
    return (newmem);
  }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]