mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-08-10 20:20:38 +02:00
Imported from ../bash-2.03.tar.gz.
This commit is contained in:
@@ -46,7 +46,7 @@
|
||||
# endif /* !__STDC__ */
|
||||
#endif /* !PTR_T */
|
||||
|
||||
#if !defined (SBRK_DECLARED)
|
||||
#if defined (HAVE_SBRK) && !defined (SBRK_DECLARED)
|
||||
extern char *sbrk();
|
||||
#endif
|
||||
|
||||
@@ -60,6 +60,19 @@ static size_t allocated;
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
#if defined (HAVE_SBRK)
|
||||
static size_t
|
||||
findbrk ()
|
||||
{
|
||||
if (brkfound == 0)
|
||||
{
|
||||
lbreak = (PTR_T)sbrk (0);
|
||||
brkfound++;
|
||||
}
|
||||
return (char *)sbrk (0) - (char *)lbreak;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Return a pointer to free()able block of memory large enough
|
||||
to hold BYTES number of bytes. If the memory cannot be allocated,
|
||||
print an error message and abort. */
|
||||
@@ -73,13 +86,12 @@ xmalloc (bytes)
|
||||
|
||||
if (temp == 0)
|
||||
{
|
||||
if (brkfound == 0)
|
||||
{
|
||||
lbreak = (PTR_T)sbrk (0);
|
||||
brkfound++;
|
||||
}
|
||||
allocated = (char *)sbrk (0) - (char *)lbreak;
|
||||
#if defined (HAVE_SBRK)
|
||||
allocated = findbrk ();
|
||||
fatal_error ("xmalloc: cannot allocate %lu bytes (%lu bytes allocated)", (unsigned long)bytes, (unsigned long)allocated);
|
||||
#else
|
||||
fatal_error ("xmalloc: cannot allocate %lu bytes", (unsigned long)bytes);
|
||||
#endif /* !HAVE_SBRK */
|
||||
}
|
||||
|
||||
return (temp);
|
||||
@@ -96,13 +108,12 @@ xrealloc (pointer, bytes)
|
||||
|
||||
if (temp == 0)
|
||||
{
|
||||
if (brkfound == 0)
|
||||
{
|
||||
lbreak = (PTR_T)sbrk (0);
|
||||
brkfound++;
|
||||
}
|
||||
allocated = (char *)sbrk (0) - (char *)lbreak;
|
||||
#if defined (HAVE_SBRK)
|
||||
allocated = findbrk ();
|
||||
fatal_error ("xrealloc: cannot reallocate %lu bytes (%lu bytes allocated)", (unsigned long)bytes, (unsigned long)allocated);
|
||||
#else
|
||||
fatal_error ("xmalloc: cannot allocate %lu bytes", (unsigned long)bytes);
|
||||
#endif /* !HAVE_SBRK */
|
||||
}
|
||||
|
||||
return (temp);
|
||||
|
||||
Reference in New Issue
Block a user