Don't check for null pointer in calls to free

According to the C99 specification section 7.20.3.2 paragraph 2:

> If ptr is a null pointer, no action occurs.

So we do not need to check that the pointer is a null pointer.
This commit is contained in:
Peter Zhu 2023-06-29 16:31:35 -04:00
parent 37a893d129
commit 58386814a7
Notes: git 2023-06-30 13:13:49 +00:00
16 changed files with 70 additions and 108 deletions

View file

@ -142,7 +142,7 @@ static void
bbuf_free(BBuf* bbuf)
{
if (IS_NOT_NULL(bbuf)) {
if (IS_NOT_NULL(bbuf->p)) xfree(bbuf->p);
xfree(bbuf->p);
xfree(bbuf);
}
}
@ -514,7 +514,7 @@ static int
i_free_name_entry(UChar* key, NameEntry* e, void* arg ARG_UNUSED)
{
xfree(e->name);
if (IS_NOT_NULL(e->back_refs)) xfree(e->back_refs);
xfree(e->back_refs);
xfree(key);
xfree(e);
return ST_DELETE;
@ -699,7 +699,7 @@ names_clear(regex_t* reg)
e->name_len = 0;
e->back_num = 0;
e->back_alloc = 0;
if (IS_NOT_NULL(e->back_refs)) xfree(e->back_refs);
xfree(e->back_refs);
e->back_refs = (int* )NULL;
}
}
@ -722,7 +722,7 @@ onig_names_free(regex_t* reg)
if (r) return r;
t = (NameTable* )reg->name_table;
if (IS_NOT_NULL(t)) xfree(t);
xfree(t);
reg->name_table = NULL;
return 0;
}
@ -1098,29 +1098,24 @@ onig_node_free(Node* node)
{
CClassNode* cc = NCCLASS(node);
if (cc->mbuf)
bbuf_free(cc->mbuf);
bbuf_free(cc->mbuf);
}
break;
case NT_QTFR:
if (NQTFR(node)->target)
onig_node_free(NQTFR(node)->target);
onig_node_free(NQTFR(node)->target);
break;
case NT_ENCLOSE:
if (NENCLOSE(node)->target)
onig_node_free(NENCLOSE(node)->target);
onig_node_free(NENCLOSE(node)->target);
break;
case NT_BREF:
if (IS_NOT_NULL(NBREF(node)->back_dynamic))
xfree(NBREF(node)->back_dynamic);
xfree(NBREF(node)->back_dynamic);
break;
case NT_ANCHOR:
if (NANCHOR(node)->target)
onig_node_free(NANCHOR(node)->target);
onig_node_free(NANCHOR(node)->target);
break;
}