/* 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);
}