From: Nicholas Clark Date: Tue, 8 Nov 2005 21:55:40 +0000 (+0000) Subject: Moving the 4 writes of PL_no_mem followed by exit(1) to a static X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ca8d897694915d32eefc26fbdc726d3457e7fedc;p=p5sagit%2Fp5-mst-13.2.git 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 --- diff --git a/util.c b/util.c index 4b115d2..e549221 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); }