-/* $OpenBSD: cl_screen.c,v 1.27 2016/05/28 18:30:35 martijn Exp $ */
+/* $OpenBSD: cl_screen.c,v 1.28 2017/04/18 01:45:33 deraadt Exp $ */
/*-
* Copyright (c) 1993, 1994
/* Enter_standout_mode and exit_standout_mode are paired. */
if (clp->smso == NULL || clp->rmso == NULL) {
- if (clp->smso != NULL) {
- free(clp->smso);
- clp->smso = NULL;
- }
- if (clp->rmso != NULL) {
- free(clp->rmso);
- clp->rmso = NULL;
- }
+ free(clp->smso);
+ clp->smso = NULL;
+ free(clp->rmso);
+ clp->rmso = NULL;
}
/*
static void
cl_freecap(CL_PRIVATE *clp)
{
- if (clp->el != NULL) {
- free(clp->el);
- clp->el = NULL;
- }
- if (clp->cup != NULL) {
- free(clp->cup);
- clp->cup = NULL;
- }
- if (clp->cuu1 != NULL) {
- free(clp->cuu1);
- clp->cuu1 = NULL;
- }
- if (clp->rmso != NULL) {
- free(clp->rmso);
- clp->rmso = NULL;
- }
- if (clp->smso != NULL) {
- free(clp->smso);
- clp->smso = NULL;
- }
+ free(clp->el);
+ clp->el = NULL;
+ free(clp->cup);
+ clp->cup = NULL;
+ free(clp->cuu1);
+ clp->cuu1 = NULL;
+ free(clp->rmso);
+ clp->rmso = NULL;
+ free(clp->smso);
+ clp->smso = NULL;
}
/*
-/* $OpenBSD: cut.c,v 1.16 2016/05/27 09:18:11 martijn Exp $ */
+/* $OpenBSD: cut.c,v 1.17 2017/04/18 01:45:35 deraadt Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
void
text_free(TEXT *tp)
{
- if (tp->lb != NULL)
- free(tp->lb);
+ free(tp->lb);
free(tp);
}
-/* $OpenBSD: exf.c,v 1.44 2016/08/01 18:27:35 bentley Exp $ */
+/* $OpenBSD: exf.c,v 1.45 2017/04/18 01:45:35 deraadt Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
TAILQ_FOREACH_SAFE(frp, &gp->frefq, q, tfrp) {
if (frp->name == NULL) {
TAILQ_REMOVE(&gp->frefq, frp, q);
- if (frp->name != NULL)
- free(frp->name);
+ free(frp->name);
free(frp);
continue;
}
F_SET(frp, FR_TMPFILE);
if ((frp->tname = strdup(tname)) == NULL ||
(frp->name == NULL && (frp->name = strdup(tname)) == NULL)) {
- if (frp->tname != NULL)
- free(frp->tname);
+ free(frp->tname);
msgq(sp, M_SYSERR, NULL);
(void)unlink(tname);
goto err;
return (0);
-err: if (frp->name != NULL) {
- free(frp->name);
- frp->name = NULL;
- }
+err:
+ free(frp->name);
+ frp->name = NULL;
if (frp->tname != NULL) {
(void)unlink(frp->tname);
free(frp->tname);
oerr: if (F_ISSET(ep, F_RCV_ON))
(void)unlink(ep->rcv_path);
- if (ep->rcv_path != NULL) {
- free(ep->rcv_path);
- ep->rcv_path = NULL;
- }
+ free(ep->rcv_path);
+ ep->rcv_path = NULL;
if (ep->db != NULL)
(void)ep->db->close(ep->db);
free(ep);
frp->tname = NULL;
if (F_ISSET(frp, FR_TMPFILE)) {
TAILQ_REMOVE(&sp->gp->frefq, frp, q);
- if (frp->name != NULL)
- free(frp->name);
+ free(frp->name);
free(frp);
}
sp->frp = NULL;
(void)close(ep->fcntl_fd);
if (ep->rcv_fd != -1)
(void)close(ep->rcv_fd);
- if (ep->rcv_path != NULL)
- free(ep->rcv_path);
- if (ep->rcv_mpath != NULL)
- free(ep->rcv_mpath);
-
+ free(ep->rcv_path);
+ free(ep->rcv_mpath);
free(ep);
return (0);
}
void
set_alt_name(SCR *sp, char *name)
{
- if (sp->alt_name != NULL)
- free(sp->alt_name);
+ free(sp->alt_name);
if (name == NULL)
sp->alt_name = NULL;
else if ((sp->alt_name = strdup(name)) == NULL)
-/* $OpenBSD: key.c,v 1.18 2016/05/27 09:18:11 martijn Exp $ */
+/* $OpenBSD: key.c,v 1.19 2017/04/18 01:45:35 deraadt Exp $ */
/*-
* Copyright (c) 1991, 1993, 1994
}
/* Free any allocated memory. */
- if (evp->e_asp != NULL)
- free(evp->e_asp);
+ free(evp->e_asp);
}
/*
-/* $OpenBSD: log.c,v 1.11 2017/01/20 00:55:52 krw Exp $ */
+/* $OpenBSD: log.c,v 1.12 2017/04/18 01:45:35 deraadt Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
(void)(ep->log->close)(ep->log);
ep->log = NULL;
}
- if (ep->l_lp != NULL) {
- free(ep->l_lp);
- ep->l_lp = NULL;
- }
+ free(ep->l_lp);
+ ep->l_lp = NULL;
ep->l_len = 0;
ep->l_cursor.lno = 1; /* XXX Any valid recno. */
ep->l_cursor.cno = 0;
-/* $OpenBSD: main.c,v 1.38 2016/05/27 09:18:11 martijn Exp $ */
+/* $OpenBSD: main.c,v 1.39 2017/04/18 01:45:35 deraadt Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
/* Free FREF's. */
while ((frp = TAILQ_FIRST(&gp->frefq))) {
TAILQ_REMOVE(&gp->frefq, frp, q);
- if (frp->name != NULL)
- free(frp->name);
- if (frp->tname != NULL)
- free(frp->tname);
+ free(frp->name);
+ free(frp->tname);
free(frp);
}
}
/* Free key input queue. */
- if (gp->i_event != NULL)
- free(gp->i_event);
+ free(gp->i_event);
/* Free cut buffers. */
cut_close(gp);
#if defined(DEBUG) || defined(PURIFY)
/* Free any temporary space. */
- if (gp->tmp_bp != NULL)
- free(gp->tmp_bp);
+ free(gp->tmp_bp);
#if defined(DEBUG)
/* Close debugging file descriptor. */
-/* $OpenBSD: options.c,v 1.22 2016/08/01 18:27:35 bentley Exp $ */
+/* $OpenBSD: options.c,v 1.23 2017/04/18 01:45:35 deraadt Exp $ */
/*-
* Copyright (c) 1991, 1993, 1994
if (optlist[cnt].type != OPT_STR ||
F_ISSET(&optlist[cnt], OPT_GLOBAL))
continue;
- if (O_STR(sp, cnt) != NULL)
- free(O_STR(sp, cnt));
- if (O_D_STR(sp, cnt) != NULL)
- free(O_D_STR(sp, cnt));
+ free(O_STR(sp, cnt));
+ free(O_D_STR(sp, cnt));
}
}
-/* $OpenBSD: screen.c,v 1.13 2015/12/07 20:39:19 mmcc Exp $ */
+/* $OpenBSD: screen.c,v 1.14 2017/04/18 01:45:35 deraadt Exp $ */
/*-
* Copyright (c) 1993, 1994
text_lfree(&sp->tiq);
/* Free alternate file name. */
- if (sp->alt_name != NULL)
- free(sp->alt_name);
+ free(sp->alt_name);
/* Free up search information. */
- if (sp->re != NULL)
- free(sp->re);
+ free(sp->re);
if (F_ISSET(sp, SC_RE_SEARCH))
regfree(&sp->re_c);
- if (sp->subre != NULL)
- free(sp->subre);
+ free(sp->subre);
if (F_ISSET(sp, SC_RE_SUBST))
regfree(&sp->subre_c);
- if (sp->repl != NULL)
- free(sp->repl);
- if (sp->newl != NULL)
- free(sp->newl);
+ free(sp->repl);
+ free(sp->newl);
/* Free all the options */
opts_free(sp);
-/* $OpenBSD: seq.c,v 1.13 2016/05/27 09:18:11 martijn Exp $ */
+/* $OpenBSD: seq.c,v 1.14 2017/04/18 01:45:35 deraadt Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
sv_errno = errno;
goto mem1;
}
- if (qp->output != NULL)
- free(qp->output);
+ free(qp->output);
qp->olen = olen;
qp->output = p;
return (0);
} else if ((qp->output = v_strdup(sp, output, olen)) == NULL) {
sv_errno = errno;
free(qp->input);
-mem3: if (qp->name != NULL)
- free(qp->name);
+mem3: free(qp->name);
mem2: free(qp);
mem1: errno = sv_errno;
msgq(sp, M_SYSERR, NULL);
seq_mdel(SEQ *qp)
{
LIST_REMOVE(qp, q);
- if (qp->name != NULL)
- free(qp->name);
+ free(qp->name);
free(qp->input);
- if (qp->output != NULL)
- free(qp->output);
+ free(qp->output);
free(qp);
return (0);
}
SEQ *qp;
while ((qp = LIST_FIRST(&gp->seqq)) != NULL) {
- if (qp->name != NULL)
- free(qp->name);
- if (qp->input != NULL)
- free(qp->input);
- if (qp->output != NULL)
- free(qp->output);
+ free(qp->name);
+ free(qp->input);
+ free(qp->output);
LIST_REMOVE(qp, q);
free(qp);
}
-/* $OpenBSD: ex_bang.c,v 1.10 2016/01/06 22:29:38 millert Exp $ */
+/* $OpenBSD: ex_bang.c,v 1.11 2017/04/18 01:45:35 deraadt Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
/* Set the "last bang command" remembered value. */
exp = EXP(sp);
- if (exp->lastbcomm != NULL)
- free(exp->lastbcomm);
+ free(exp->lastbcomm);
if ((exp->lastbcomm = strdup(ap->bp)) == NULL) {
msgq(sp, M_SYSERR, NULL);
return (1);
-/* $OpenBSD: ex_init.c,v 1.17 2016/01/06 22:28:52 millert Exp $ */
+/* $OpenBSD: ex_init.c,v 1.18 2017/04/18 01:45:35 deraadt Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
if (argv_free(sp))
rval = 1;
- if (exp->ibp != NULL)
- free(exp->ibp);
-
- if (exp->lastbcomm != NULL)
- free(exp->lastbcomm);
+ free(exp->ibp);
+ free(exp->lastbcomm);
if (ex_tag_free(sp))
rval = 1;
-/* $OpenBSD: ex_read.c,v 1.13 2016/05/27 09:18:12 martijn Exp $ */
+/* $OpenBSD: ex_read.c,v 1.14 2017/04/18 01:45:35 deraadt Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
/* Set the last bang command. */
exp = EXP(sp);
- if (exp->lastbcomm != NULL)
- free(exp->lastbcomm);
+ free(exp->lastbcomm);
if ((exp->lastbcomm =
strdup(cmdp->argv[argc]->bp)) == NULL) {
msgq(sp, M_SYSERR, NULL);
-/* $OpenBSD: ex_script.c,v 1.26 2016/05/27 09:18:12 martijn Exp $ */
+/* $OpenBSD: ex_script.c,v 1.27 2017/04/18 01:45:35 deraadt Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
SCRIPT *sc;
sc = sp->script;
- if (sc->sh_prompt)
- free(sc->sh_prompt);
+ free(sc->sh_prompt);
MALLOC(sp, sc->sh_prompt, len + 1);
if (sc->sh_prompt == NULL) {
sscr_end(sp);
-/* $OpenBSD: ex_subst.c,v 1.29 2016/09/02 15:38:42 martijn Exp $ */
+/* $OpenBSD: ex_subst.c,v 1.30 2017/04/18 01:45:35 deraadt Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
if (p[0] == '\0' || p[0] == delim) {
if (p[0] == delim)
++p;
- if (sp->repl != NULL)
- free(sp->repl);
+ free(sp->repl);
sp->repl = NULL;
sp->repl_len = 0;
} else if (p[0] == '%' && (p[1] == '\0' || p[1] == delim))
++len;
}
if ((sp->repl_len = len) != 0) {
- if (sp->repl != NULL)
- free(sp->repl);
+ free(sp->repl);
if ((sp->repl = malloc(len)) == NULL) {
msgq(sp, M_SYSERR, NULL);
FREE_SPACE(sp, bp, blen);
if (bp != NULL)
FREE_SPACE(sp, bp, blen);
- if (lb != NULL)
- free(lb);
+ free(lb);
return (rval);
}
return (1);
/* Discard previous pattern. */
- if (*ptrnp != NULL) {
- free(*ptrnp);
- *ptrnp = NULL;
- }
+ free(*ptrnp);
+ *ptrnp = NULL;
if (lenp != NULL)
*lenp = plen;
-/* $OpenBSD: ex_tag.c,v 1.24 2016/01/06 22:28:52 millert Exp $ */
+/* $OpenBSD: ex_tag.c,v 1.25 2017/04/18 01:45:35 deraadt Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
exp = EXP(sp);
switch (cmdp->argc) {
case 1:
- if (exp->tag_last != NULL)
- free(exp->tag_last);
+ free(exp->tag_last);
if ((exp->tag_last = strdup(cmdp->argv[0]->bp)) == NULL) {
msgq(sp, M_SYSERR, NULL);
err:
alloc_err:
- if (rtqp != NULL)
- free(rtqp);
- if (rtp != NULL)
- free(rtp);
+ free(rtqp);
+ free(rtp);
tagq_free(sp, tqp);
return (1);
}
tagq_free(sp, tqp); /* tagq_free removes tqp from queue. */
while ((tfp = TAILQ_FIRST(&exp->tagfq)) != NULL)
tagf_free(sp, tfp);
- if (exp->tag_last != NULL)
- free(exp->tag_last);
+ free(exp->tag_last);
return (0);
}
-/* $OpenBSD: v_init.c,v 1.7 2015/12/07 20:39:19 mmcc Exp $ */
+/* $OpenBSD: v_init.c,v 1.8 2017/04/18 01:45:35 deraadt Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
if ((vip = VIP(sp)) == NULL)
return (0);
- if (vip->keyw != NULL)
- free(vip->keyw);
- if (vip->rep != NULL)
- free(vip->rep);
- if (vip->ps != NULL)
- free(vip->ps);
-
- if (HMAP != NULL)
- free(HMAP);
-
+ free(vip->keyw);
+ free(vip->rep);
+ free(vip->ps);
+ free(HMAP);
free(vip);
sp->vi_private = NULL;
-/* $OpenBSD: v_paragraph.c,v 1.8 2015/12/07 20:39:19 mmcc Exp $ */
+/* $OpenBSD: v_paragraph.c,v 1.9 2017/04/18 01:45:35 deraadt Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
MALLOC_RET(sp, p, p_len + s_len + 1);
vip = VIP(sp);
- if (vip->ps != NULL)
- free(vip->ps);
+ free(vip->ps);
if (p_p != NULL)
memmove(p, p_p, p_len + 1);
-/* $OpenBSD: vi.c,v 1.20 2016/05/27 09:18:12 martijn Exp $ */
+/* $OpenBSD: vi.c,v 1.21 2017/04/18 01:45:35 deraadt Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
hidden = 0;
gp = sp->gp;
while ((tsp = TAILQ_FIRST(&gp->dq))) {
- if (_HMAP(tsp) != NULL) {
- free(_HMAP(tsp));
- _HMAP(tsp) = NULL;
- }
+ free(_HMAP(tsp));
+ _HMAP(tsp) = NULL;
TAILQ_REMOVE(&gp->dq, tsp, q);
TAILQ_INSERT_TAIL(&gp->hq, tsp, q);
++hidden;
-/* $OpenBSD: vs_msg.c,v 1.19 2016/12/18 06:11:23 krw Exp $ */
+/* $OpenBSD: vs_msg.c,v 1.20 2017/04/18 01:45:35 deraadt Exp $ */
/*-
* Copyright (c) 1993, 1994
return;
alloc_err:
- if (mp_n != NULL)
- free(mp_n);
+ free(mp_n);
(void)fprintf(stderr, "%.*s\n", (int)len, p);
}