summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2005-07-02 12:34:08 +0000
committerNicholas Clark <nick@ccl4.org>2005-07-02 12:34:08 +0000
commit43c5f42db1e336a99904bcc798b7070727bfbd0a (patch)
tree1e02933dfd6fac99b7933947f33451769fd8467e
parent0cf8ddea3351f0ff9eef736dfa13bc866d0d1f97 (diff)
downloadperl-43c5f42db1e336a99904bcc798b7070727bfbd0a.tar.gz
Don't check the pointer is non-NULL before calling Safefree() in
little used code, code used only once per run (such as interpreter construction and destruction), and cases where the pointer nearly never is NULL. Safefree does its own non-NULL check, and even that isn't strictly necessary as all conformant free()s accept a NULL pointer. p4raw-id: //depot/perl@25045
-rw-r--r--doio.c12
-rw-r--r--locale.c15
-rw-r--r--mg.c15
-rw-r--r--perl.c9
-rw-r--r--perl.h2
-rw-r--r--regcomp.c17
-rw-r--r--sv.c3
-rw-r--r--util.c3
8 files changed, 26 insertions, 50 deletions
diff --git a/doio.c b/doio.c
index b62a473824..c1b11d3e6c 100644
--- a/doio.c
+++ b/doio.c
@@ -1497,14 +1497,10 @@ Perl_do_aexec5(pTHX_ SV *really, register SV **mark, register SV **sp,
void
Perl_do_execfree(pTHX)
{
- if (PL_Argv) {
- Safefree(PL_Argv);
- PL_Argv = Null(char **);
- }
- if (PL_Cmd) {
- Safefree(PL_Cmd);
- PL_Cmd = Nullch;
- }
+ Safefree(PL_Argv);
+ PL_Argv = Null(char **);
+ Safefree(PL_Cmd);
+ PL_Cmd = Nullch;
}
#if !defined(OS2) && !defined(WIN32) && !defined(DJGPP) && !defined(EPOC) && !defined(SYMBIAN) && !defined(MACOS_TRADITIONAL)
diff --git a/locale.c b/locale.c
index 77a83fd850..40d2a4415e 100644
--- a/locale.c
+++ b/locale.c
@@ -112,10 +112,8 @@ Perl_new_numeric(pTHX_ const char *newnum)
#ifdef USE_LOCALE_NUMERIC
if (! newnum) {
- if (PL_numeric_name) {
- Safefree(PL_numeric_name);
- PL_numeric_name = NULL;
- }
+ Safefree(PL_numeric_name);
+ PL_numeric_name = NULL;
PL_numeric_standard = TRUE;
PL_numeric_local = TRUE;
return;
@@ -534,16 +532,13 @@ Perl_init_i18nl10n(pTHX_ int printwarn)
#endif
#ifdef USE_LOCALE_CTYPE
- if (curctype != NULL)
- Safefree(curctype);
+ Safefree(curctype);
#endif /* USE_LOCALE_CTYPE */
#ifdef USE_LOCALE_COLLATE
- if (curcoll != NULL)
- Safefree(curcoll);
+ Safefree(curcoll);
#endif /* USE_LOCALE_COLLATE */
#ifdef USE_LOCALE_NUMERIC
- if (curnum != NULL)
- Safefree(curnum);
+ Safefree(curnum);
#endif /* USE_LOCALE_NUMERIC */
return ok;
}
diff --git a/mg.c b/mg.c
index dcc3a90c24..6d820705ff 100644
--- a/mg.c
+++ b/mg.c
@@ -2215,19 +2215,12 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg)
PL_hints = SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv);
break;
case '\011': /* ^I */ /* NOT \t in EBCDIC */
- if (PL_inplace)
- Safefree(PL_inplace);
- if (SvOK(sv))
- PL_inplace = savesvpv(sv);
- else
- PL_inplace = Nullch;
- break;
+ Safefree(PL_inplace);
+ PL_inplace = SvOK(sv) ? savesvpv(sv) : Nullch;
case '\017': /* ^O */
if (*(mg->mg_ptr+1) == '\0') {
- if (PL_osname) {
- Safefree(PL_osname);
- PL_osname = Nullch;
- }
+ Safefree(PL_osname);
+ PL_osname = Nullch;
if (SvOK(sv)) {
TAINT_PROPER("assigning to $^O");
PL_osname = savesvpv(sv);
diff --git a/perl.c b/perl.c
index 5d5ec62397..4bafb31e30 100644
--- a/perl.c
+++ b/perl.c
@@ -1208,8 +1208,7 @@ perl_destruct(pTHXx)
Safefree(PL_reg_start_tmp);
PL_reg_start_tmp = (char**)NULL;
PL_reg_start_tmpl = 0;
- if (PL_reg_curpm)
- Safefree(PL_reg_curpm);
+ Safefree(PL_reg_curpm);
Safefree(PL_reg_poscache);
free_tied_hv_pool();
Safefree(PL_op_mask);
@@ -2968,8 +2967,7 @@ Perl_moreswitches(pTHX_ char *s)
usage(PL_origargv[0]);
my_exit(0);
case 'i':
- if (PL_inplace)
- Safefree(PL_inplace);
+ Safefree(PL_inplace);
#if defined(__CYGWIN__) /* do backup extension automagically */
if (*(s+1) == '\0') {
PL_inplace = savepv(".bak");
@@ -4405,8 +4403,7 @@ S_init_predump_symbols(pTHX)
PL_statname = NEWSV(66,0); /* last filename we did stat on */
- if (PL_osname)
- Safefree(PL_osname);
+ Safefree(PL_osname);
PL_osname = savepv(OSNAME);
}
diff --git a/perl.h b/perl.h
index 9de12912f6..22d41f16fb 100644
--- a/perl.h
+++ b/perl.h
@@ -4764,7 +4764,7 @@ typedef struct am_table_short AMTS;
new_chunk = (void *)(chunk); \
new_chunk_size = (chunk_size); \
if (new_chunk_size > PL_nice_chunk_size) { \
- if (PL_nice_chunk) Safefree(PL_nice_chunk); \
+ Safefree(PL_nice_chunk); \
PL_nice_chunk = (char *) new_chunk; \
PL_nice_chunk_size = new_chunk_size; \
} else { \
diff --git a/regcomp.c b/regcomp.c
index d2526b7276..57f5834dea 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -6007,10 +6007,10 @@ Perl_pregfree(pTHX_ struct regexp *r)
len > 60 ? "..." : "");
});
- if (r->precomp)
- Safefree(r->precomp);
- if (r->offsets) /* 20010421 MJD */
- Safefree(r->offsets);
+ /* gcov results gave these as non-null 100% of the time, so there's no
+ optimisation in checking them before calling Safefree */
+ Safefree(r->precomp);
+ Safefree(r->offsets); /* 20010421 MJD */
RX_MATCH_COPY_FREE(r);
#ifdef PERL_OLD_COPY_ON_WRITE
if (r->saved_copy)
@@ -6073,14 +6073,11 @@ Perl_pregfree(pTHX_ struct regexp *r)
refcount = trie->refcount--;
OP_REFCNT_UNLOCK;
if ( !refcount ) {
- if (trie->charmap)
- Safefree(trie->charmap);
+ Safefree(trie->charmap);
if (trie->widecharmap)
SvREFCNT_dec((SV*)trie->widecharmap);
- if (trie->states)
- Safefree(trie->states);
- if (trie->trans)
- Safefree(trie->trans);
+ Safefree(trie->states);
+ Safefree(trie->trans);
#ifdef DEBUGGING
if (trie->words)
SvREFCNT_dec((SV*)trie->words);
diff --git a/sv.c b/sv.c
index 35af580364..e3a8a29fba 100644
--- a/sv.c
+++ b/sv.c
@@ -572,8 +572,7 @@ Perl_sv_free_arenas(pTHX)
free_arena(pte);
#endif
- if (PL_nice_chunk)
- Safefree(PL_nice_chunk);
+ Safefree(PL_nice_chunk);
PL_nice_chunk = Nullch;
PL_nice_chunk_size = 0;
PL_sv_arenaroot = 0;
diff --git a/util.c b/util.c
index 4da13d4522..c65ccce82f 100644
--- a/util.c
+++ b/util.c
@@ -2959,8 +2959,7 @@ Perl_find_script(pTHX_ const char *scriptname, bool dosearch, const char **searc
}
scriptname = Nullch;
}
- if (xfailed)
- Safefree(xfailed);
+ Safefree(xfailed);
scriptname = xfound;
}
return (scriptname ? savepv(scriptname) : Nullch);