summaryrefslogtreecommitdiff
path: root/gnu
diff options
context:
space:
mode:
authorPascal Stumpf <pascal@cvs.openbsd.org>2015-10-20 11:15:08 +0000
committerPascal Stumpf <pascal@cvs.openbsd.org>2015-10-20 11:15:08 +0000
commit497a2ad4ed74864c190d7e42bd79f53c1f74c42b (patch)
treef8b82c1bb8dac5eeb9b3791d46f14ab0c6536c8c /gnu
parent74152a9154b72399227b5bfa66a96b37f10ffff3 (diff)
On xmalloc failure, stop trying to determine the total amount of allocated
memory up to this point by using sbrk(2). This is of course wildly incorrect for any mmap-based malloc(3). This also makes it possible to bring pledge(2) to gnu/. comments kettenis@, ok miod@
Diffstat (limited to 'gnu')
-rw-r--r--gnu/lib/libiberty/src/xmalloc.c25
1 files changed, 0 insertions, 25 deletions
diff --git a/gnu/lib/libiberty/src/xmalloc.c b/gnu/lib/libiberty/src/xmalloc.c
index 3e97aab563f..5c95b8b0dd9 100644
--- a/gnu/lib/libiberty/src/xmalloc.c
+++ b/gnu/lib/libiberty/src/xmalloc.c
@@ -96,44 +96,19 @@ void *sbrk (ptrdiff_t);
/* The program name if set. */
static const char *name = "";
-#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 /* HAVE_SBRK */
-
void
xmalloc_set_program_name (const char *s)
{
name = s;
-#ifdef HAVE_SBRK
- /* Win32 ports other than cygwin32 don't have brk() */
- if (first_break == NULL)
- first_break = (char *) sbrk (0);
-#endif /* HAVE_SBRK */
}
void
xmalloc_failed (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%sout of memory allocating %lu bytes after a total of %lu bytes\n",
- name, *name ? ": " : "",
- (unsigned long) size, (unsigned long) allocated);
-#else /* HAVE_SBRK */
fprintf (stderr,
"\n%s%sout of memory allocating %lu bytes\n",
name, *name ? ": " : "",
(unsigned long) size);
-#endif /* HAVE_SBRK */
xexit (1);
}