summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2005-11-08 21:55:40 +0000
committerNicholas Clark <nick@ccl4.org>2005-11-08 21:55:40 +0000
commitca8d897694915d32eefc26fbdc726d3457e7fedc (patch)
tree9c5a1c2767ba8b5b6af0a602b6e0f99d5c6f987d /util.c
parent42d9b98d3f03094883cfc4bb765785a6d4396077 (diff)
downloadperl-ca8d897694915d32eefc26fbdc726d3457e7fedc.tar.gz
Moving the 4 writes of PL_no_mem followed by exit(1) to a static
function makes the object code slightly smaller. p4raw-id: //depot/perl@26051
Diffstat (limited to 'util.c')
-rw-r--r--util.c32
1 files changed, 14 insertions, 18 deletions
diff --git a/util.c b/util.c
index 4b115d28c8..e549221741 100644
--- a/util.c
+++ b/util.c
@@ -57,6 +57,16 @@ int putenv(char *);
* XXX This advice seems to be widely ignored :-( --AD August 1996.
*/
+static char *
+S_write_no_mem(pTHX)
+{
+ /* Can't use PerlIO to write as it allocates memory */
+ PerlLIO_write(PerlIO_fileno(Perl_error_log),
+ PL_no_mem, strlen(PL_no_mem));
+ my_exit(1);
+ return Nullch;
+}
+
/* paranoid version of system's malloc() */
Malloc_t
@@ -83,11 +93,7 @@ Perl_safesysmalloc(MEM_SIZE size)
else if (PL_nomemok)
return Nullch;
else {
- /* Can't use PerlIO to write as it allocates memory */
- PerlLIO_write(PerlIO_fileno(Perl_error_log),
- PL_no_mem, strlen(PL_no_mem));
- my_exit(1);
- return Nullch;
+ return S_write_no_mem(aTHX);
}
/*NOTREACHED*/
}
@@ -132,11 +138,7 @@ Perl_safesysrealloc(Malloc_t where,MEM_SIZE size)
else if (PL_nomemok)
return Nullch;
else {
- /* Can't use PerlIO to write as it allocates memory */
- PerlLIO_write(PerlIO_fileno(Perl_error_log),
- PL_no_mem, strlen(PL_no_mem));
- my_exit(1);
- return Nullch;
+ return S_write_no_mem(aTHX);
}
/*NOTREACHED*/
}
@@ -186,11 +188,7 @@ Perl_safesyscalloc(MEM_SIZE count, MEM_SIZE size)
else if (PL_nomemok)
return Nullch;
else {
- /* Can't use PerlIO to write as it allocates memory */
- PerlLIO_write(PerlIO_fileno(Perl_error_log),
- PL_no_mem, strlen(PL_no_mem));
- my_exit(1);
- return Nullch;
+ return S_write_no_mem(aTHX);
}
/*NOTREACHED*/
}
@@ -819,9 +817,7 @@ Perl_savesharedpv(pTHX_ const char *pv)
pvlen = strlen(pv)+1;
newaddr = (char*)PerlMemShared_malloc(pvlen);
if (!newaddr) {
- PerlLIO_write(PerlIO_fileno(Perl_error_log),
- PL_no_mem, strlen(PL_no_mem));
- my_exit(1);
+ return S_write_no_mem(aTHX);
}
return memcpy(newaddr,pv,pvlen);
}