-/* $OpenBSD: buf.c,v 1.24 2015/02/05 12:59:58 millert Exp $ */
+/* $OpenBSD: buf.c,v 1.25 2015/06/13 20:15:21 nicm Exp $ */
/*
* Copyright (c) 2003 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
#include <fcntl.h>
#include <stdint.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <unistd.h>
void
buf_free(BUF *b)
{
- if (b->cb_buf != NULL)
- xfree(b->cb_buf);
- xfree(b);
+ free(b->cb_buf);
+ free(b);
}
/*
* Free the buffer <b>'s structural information but do not free the contents
* of the buffer. Instead, they are returned and should be freed later using
- * xfree().
+ * free().
*/
void *
buf_release(BUF *b)
void *tmp;
tmp = b->cb_buf;
- xfree(b);
+ free(b);
return (tmp);
}
-/* $OpenBSD: ci.c,v 1.219 2015/01/16 06:40:11 deraadt Exp $ */
+/* $OpenBSD: ci.c,v 1.220 2015/06/13 20:15:21 nicm Exp $ */
/*
* Copyright (c) 2005, 2006 Niall O'Higgins <niallo@openbsd.org>
* All rights reserved.
exit(0);
case 'w':
if (pb.author != NULL)
- xfree(pb.author);
+ free(pb.author);
pb.author = xstrdup(rcs_optarg);
break;
case 'x':
buf_free(b2);
if (b3 != NULL)
buf_free(b3);
- if (path1 != NULL)
- xfree(path1);
- if (path2 != NULL)
- xfree(path2);
+ free(path1);
+ free(path2);
return (NULL);
}
fprintf(stderr,
"reuse log message of previous file? [yn](y): ");
if (rcs_yesno('y') != 'y') {
- xfree(pb->rcs_msg);
+ free(pb->rcs_msg);
pb->rcs_msg = NULL;
}
}
pb->username, pb->author, NULL, NULL);
if ((pb->flags & INTERACTIVE) && (pb->rcs_msg[0] == '\0')) {
- xfree(pb->rcs_msg); /* free empty log message */
+ free(pb->rcs_msg); /* free empty log message */
pb->rcs_msg = NULL;
}
(void)xasprintf(&datestring, "%s %s", tokens[3], tokens[4]);
if ((*date = date_parse(datestring)) == -1)
errx(1, "could not parse date");
- xfree(datestring);
+ free(datestring);
if (i < 6)
break;
- if (*author != NULL)
- xfree(*author);
+ free(*author);
*author = xstrdup(tokens[5]);
if (i < 7)
break;
- if (*state != NULL)
- xfree(*state);
+ free(*state);
*state = xstrdup(tokens[6]);
break;
case KW_TYPE_AUTHOR:
if (i < 2)
break;
- if (*author != NULL)
- xfree(*author);
+ free(*author);
*author = xstrdup(tokens[1]);
break;
case KW_TYPE_DATE:
(void)xasprintf(&datestring, "%s %s", tokens[1], tokens[2]);
if ((*date = date_parse(datestring)) == -1)
errx(1, "could not parse date");
- xfree(datestring);
+ free(datestring);
break;
case KW_TYPE_STATE:
if (i < 2)
break;
- if (*state != NULL)
- xfree(*state);
+ free(*state);
*state = xstrdup(tokens[1]);
break;
case KW_TYPE_REVISION:
-/* $OpenBSD: co.c,v 1.120 2015/01/16 06:40:11 deraadt Exp $ */
+/* $OpenBSD: co.c,v 1.121 2015/06/13 20:15:21 nicm Exp $ */
/*
* Copyright (c) 2005 Joris Vink <joris@openbsd.org>
* All rights reserved.
buf_free(bp);
unlink(tempfile);
- xfree(tempfile);
+ free(tempfile);
return (ret);
}
%{
-/* $OpenBSD: date.y,v 1.12 2013/12/03 00:21:49 deraadt Exp $ */
+/* $OpenBSD: date.y,v 1.13 2015/06/13 20:15:21 nicm Exp $ */
/*
** Originally written by Steven M. Bellovin <smb@research.att.com> while
s, yyInput);
warnx("%s", str);
- xfree(str);
+ free(str);
return (0);
}
-/* $OpenBSD: diff.c,v 1.37 2015/01/16 06:40:11 deraadt Exp $ */
+/* $OpenBSD: diff.c,v 1.38 2015/06/13 20:15:21 nicm Exp $ */
/*
* Copyright (C) Caldera International Inc. 2001-2002.
* All rights reserved.
#include <stdint.h>
#include <stddef.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <limits.h>
clistlen = 100;
clist = xcalloc(clistlen, sizeof(*clist));
i = stone(class, slen[0], member, klist, flags);
- xfree(member);
- xfree(class);
+ free(member);
+ free(class);
J = xreallocarray(J, len[0] + 2, sizeof(*J));
unravel(klist[i]);
- xfree(clist);
- xfree(klist);
+ free(clist);
+ free(klist);
ixold = xreallocarray(ixold, len[0] + 2, sizeof(*ixold));
ixnew = xreallocarray(ixnew, len[1] + 2, sizeof(*ixnew));
a[f[i].serial] = f[i].value;
for (i = 1; i <= l; i++)
b[i] = a[i];
- xfree(a);
+ free(a);
}
static int
int ret;
ret = regexec(diff_ignore_re, line, 0, NULL, 0);
- xfree(line);
+ free(line);
return (ret == 0); /* if it matched, it should be ignored. */
}
buf_append(diffbuf, str, strlen(str));
else
printf("%s", str);
- xfree(str);
+ free(str);
}
-/* $OpenBSD: diff3.c,v 1.35 2015/01/16 06:40:11 deraadt Exp $ */
+/* $OpenBSD: diff3.c,v 1.36 2015/06/13 20:15:21 nicm Exp $ */
/*
* Copyright (C) Caldera International Inc. 2001-2002.
(void)unlink(dp13);
(void)unlink(dp23);
- if (path1 != NULL)
- xfree(path1);
- if (path2 != NULL)
- xfree(path2);
- if (path3 != NULL)
- xfree(path3);
- if (dp13 != NULL)
- xfree(dp13);
- if (dp23 != NULL)
- xfree(dp23);
- if (data != NULL)
- xfree(data);
- if (patch != NULL)
- xfree(patch);
+ free(path1);
+ free(path2);
+ free(path3);
+ free(dp13);
+ free(dp23);
+ free(data);
+ free(patch);
return (diffb);
}
(void)unlink(dp13);
(void)unlink(dp23);
- if (path1 != NULL)
- xfree(path1);
- if (path2 != NULL)
- xfree(path2);
- if (path3 != NULL)
- xfree(path3);
- if (dp13 != NULL)
- xfree(dp13);
- if (dp23 != NULL)
- xfree(dp23);
- if (data != NULL)
- xfree(data);
- if (patch != NULL)
- xfree(patch);
+ free(path1);
+ free(path2);
+ free(path3);
+ free(dp13);
+ free(dp23);
+ free(data);
+ free(patch);
return (diffb);
}
-/* $OpenBSD: rcs.c,v 1.82 2015/01/16 06:40:11 deraadt Exp $ */
+/* $OpenBSD: rcs.c,v 1.83 2015/06/13 20:15:21 nicm Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
while (!TAILQ_EMPTY(&(rfp->rf_access))) {
rap = TAILQ_FIRST(&(rfp->rf_access));
TAILQ_REMOVE(&(rfp->rf_access), rap, ra_list);
- xfree(rap->ra_name);
- xfree(rap);
+ free(rap->ra_name);
+ free(rap);
}
while (!TAILQ_EMPTY(&(rfp->rf_symbols))) {
rsp = TAILQ_FIRST(&(rfp->rf_symbols));
TAILQ_REMOVE(&(rfp->rf_symbols), rsp, rs_list);
rcsnum_free(rsp->rs_num);
- xfree(rsp->rs_name);
- xfree(rsp);
+ free(rsp->rs_name);
+ free(rsp);
}
while (!TAILQ_EMPTY(&(rfp->rf_locks))) {
rlp = TAILQ_FIRST(&(rfp->rf_locks));
TAILQ_REMOVE(&(rfp->rf_locks), rlp, rl_list);
rcsnum_free(rlp->rl_num);
- xfree(rlp->rl_name);
- xfree(rlp);
+ free(rlp->rl_name);
+ free(rlp);
}
if (rfp->rf_head != NULL)
if (rfp->rf_file != NULL)
fclose(rfp->rf_file);
- if (rfp->rf_path != NULL)
- xfree(rfp->rf_path);
- if (rfp->rf_comment != NULL)
- xfree(rfp->rf_comment);
- if (rfp->rf_expand != NULL)
- xfree(rfp->rf_expand);
- if (rfp->rf_desc != NULL)
- xfree(rfp->rf_desc);
+
+ free(rfp->rf_path);
+ free(rfp->rf_comment);
+ free(rfp->rf_expand);
+ free(rfp->rf_desc);
if (rfp->rf_pdata != NULL)
rcsparse_free(rfp);
- xfree(rfp);
+
+ free(rfp);
}
/*
rfp->rf_flags |= RCS_SYNCED;
- if (fn != NULL)
- xfree(fn);
+ free(fn);
}
/*
out:
(void)fclose(src);
(void)fclose(dst);
- xfree(buf);
+ free(buf);
return (0);
}
}
TAILQ_REMOVE(&(file->rf_access), ap, ra_list);
- xfree(ap->ra_name);
- xfree(ap);
+ free(ap->ra_name);
+ free(ap);
/* not synced anymore */
file->rf_flags &= ~RCS_SYNCED;
}
TAILQ_REMOVE(&(file->rf_symbols), symp, rs_list);
- xfree(symp->rs_name);
+ free(symp->rs_name);
rcsnum_free(symp->rs_num);
- xfree(symp);
+ free(symp);
/* not synced anymore */
file->rf_flags &= ~RCS_SYNCED;
TAILQ_REMOVE(&(file->rf_locks), lkp, rl_list);
rcsnum_free(lkp->rl_num);
- xfree(lkp->rl_name);
- xfree(lkp);
+ free(lkp->rl_name);
+ free(lkp);
/* not synced anymore */
file->rf_flags &= ~RCS_SYNCED;
char *tmp;
tmp = xstrdup(desc);
- if (file->rf_desc != NULL)
- xfree(file->rf_desc);
+ free(file->rf_desc);
file->rf_desc = tmp;
file->rf_flags &= ~RCS_SYNCED;
}
char *tmp;
tmp = xstrdup(comment);
- if (file->rf_comment != NULL)
- xfree(file->rf_comment);
+ free(file->rf_comment);
file->rf_comment = tmp;
file->rf_flags &= ~RCS_SYNCED;
}
for (i = 0; (i < nbln) && (dlp != NULL); i++) {
ndlp = TAILQ_NEXT(dlp, l_list);
TAILQ_REMOVE(&(dlines->l_lines), dlp, l_list);
- xfree(dlp);
+ free(dlp);
dlp = ndlp;
/* last line is gone - reset dlp */
if (dlp == NULL) {
return (NULL);
rbuf = rcs_patchfile(data, dlen, patch, plen, rcs_patch_lines);
- xfree(data);
+ free(data);
if (rbuf == NULL)
break;
rcs_freedelta(rdp);
- if (path_tmp1 != NULL)
- xfree(path_tmp1);
- if (path_tmp2 != NULL)
- xfree(path_tmp2);
+ free(path_tmp1);
+ free(path_tmp2);
return (0);
}
}
tmp = xstrdup(buf);
- if (file->rf_expand != NULL)
- xfree(file->rf_expand);
+ free(file->rf_expand);
file->rf_expand = tmp;
/* not synced anymore */
file->rf_flags &= ~RCS_SYNCED;
if (rdp->rd_next != NULL)
rcsnum_free(rdp->rd_next);
- if (rdp->rd_author != NULL)
- xfree(rdp->rd_author);
- if (rdp->rd_locker != NULL)
- xfree(rdp->rd_locker);
- if (rdp->rd_state != NULL)
- xfree(rdp->rd_state);
- if (rdp->rd_log != NULL)
- xfree(rdp->rd_log);
- if (rdp->rd_text != NULL)
- xfree(rdp->rd_text);
+ free(rdp->rd_author);
+ free(rdp->rd_locker);
+ free(rdp->rd_state);
+ free(rdp->rd_log);
+ free(rdp->rd_text);
while ((rb = TAILQ_FIRST(&(rdp->rd_branches))) != NULL) {
TAILQ_REMOVE(&(rdp->rd_branches), rb, rb_list);
rcsnum_free(rb->rb_num);
- xfree(rb);
+ free(rb);
}
- xfree(rdp);
+ free(rdp);
}
/*
if ((rdp = rcs_findrev(rfp, rev)) == NULL)
return (-1);
- if (rdp->rd_text != NULL)
- xfree(rdp->rd_text);
+ free(rdp->rd_text);
len = buf_len(bp);
dtext = buf_release(bp);
rdp->rd_tlen = 0;
}
- if (dtext != NULL)
- xfree(dtext);
+ free(dtext);
return (0);
}
if ((rdp = rcs_findrev(rfp, rev)) == NULL)
return (-1);
- if (rdp->rd_log != NULL)
- xfree(rdp->rd_log);
+ free(rdp->rd_log);
rdp->rd_log = xstrdup(logtext);
rfp->rf_flags &= ~RCS_SYNCED;
if ((rdp = rcs_findrev(rfp, rev)) == NULL)
return (-1);
- if (rdp->rd_state != NULL)
- xfree(rdp->rd_state);
+ free(rdp->rd_state);
rdp->rd_state = xstrdup(state);
-/* $OpenBSD: rcsdiff.c,v 1.82 2015/01/16 06:40:11 deraadt Exp $ */
+/* $OpenBSD: rcsdiff.c,v 1.83 2015/06/13 20:15:21 nicm Exp $ */
/*
* Copyright (c) 2005 Joris Vink <joris@openbsd.org>
* All rights reserved.
buf_free(b1);
if (b2 != NULL)
buf_free(b2);
- if (path1 != NULL)
- xfree(path1);
- if (path2 != NULL)
- xfree(path2);
+ free(path1);
+ free(path2);
return (ret);
}
buf_free(b1);
if (b2 != NULL)
buf_free(b2);
- if (path1 != NULL)
- xfree(path1);
- if (path2 != NULL)
- xfree(path2);
+ free(path1);
+ free(path2);
return (ret);
}
-/* $OpenBSD: rcsnum.c,v 1.16 2015/01/16 06:40:11 deraadt Exp $ */
+/* $OpenBSD: rcsnum.c,v 1.17 2015/06/13 20:15:21 nicm Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
#include <ctype.h>
#include <err.h>
+#include <stdlib.h>
#include <string.h>
#include <limits.h>
void
rcsnum_free(RCSNUM *rn)
{
- if (rn->rn_id != NULL)
- xfree(rn->rn_id);
- xfree(rn);
+ free(rn->rn_id);
+ free(rn);
}
/*
rcsnum_aton_failed:
nump->rn_len = 0;
- xfree(nump->rn_id);
+ free(nump->rn_id);
nump->rn_id = NULL;
return (-1);
}
-/* $OpenBSD: rcsparse.c,v 1.14 2014/12/01 21:58:46 deraadt Exp $ */
+/* $OpenBSD: rcsparse.c,v 1.15 2015/06/13 20:15:21 nicm Exp $ */
/*
* Copyright (c) 2010 Tobias Stoeckmann <tobias@openbsd.org>
*
pdp = rfp->rf_pdata;
- if (pdp->rp_buf != NULL)
- xfree(pdp->rp_buf);
+ free(pdp->rp_buf);
if (pdp->rp_token == RCS_TYPE_REVISION)
rcsnum_free(pdp->rp_value.rev);
- xfree(pdp);
+ free(pdp);
}
/*
memcpy(pdp->rp_delta->rd_text, pdp->rp_buf,
pdp->rp_delta->rd_tlen);
}
- xfree(pdp->rp_value.str);
+ free(pdp->rp_value.str);
return (0);
}
name = pdp->rp_value.str;
if (rcsparse_token(rfp, RCS_TOK_COLON) != RCS_TOK_COLON ||
rcsparse_token(rfp, RCS_TYPE_NUMBER) != RCS_TYPE_NUMBER) {
- xfree(name);
+ free(name);
return (1);
}
symp = xmalloc(sizeof(*symp));
if (rcsparse_token(rfp, RCS_TOK_COLON) != RCS_TOK_COLON ||
rcsparse_token(rfp, RCS_TYPE_REVISION) !=
RCS_TYPE_REVISION) {
- xfree(name);
+ free(name);
return (1);
}
lkp = xmalloc(sizeof(*lkp));
-/* $OpenBSD: rcsprog.c,v 1.155 2015/01/16 06:40:11 deraadt Exp $ */
+/* $OpenBSD: rcsprog.c,v 1.156 2015/06/13 20:15:21 nicm Exp $ */
/*
* Copyright (c) 2005 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
rcsflags |= RCSPROG_LFLAG;
break;
case 'm':
- if (logstr != NULL)
- xfree(logstr);
+ free(logstr);
logstr = xstrdup(rcs_optarg);
break;
case 'M':
while (!TAILQ_EMPTY(&(file->rf_access))) {
rap = TAILQ_FIRST(&(file->rf_access));
TAILQ_REMOVE(&(file->rf_access), rap, ra_list);
- xfree(rap->ra_name);
- xfree(rap);
+ free(rap->ra_name);
+ free(rap);
}
/* not synced anymore */
file->rf_flags &= ~RCS_SYNCED;
-/* $OpenBSD: rcsutil.c,v 1.43 2015/01/16 06:40:11 deraadt Exp $ */
+/* $OpenBSD: rcsutil.c,v 1.44 2015/06/13 20:15:21 nicm Exp $ */
/*
* Copyright (c) 2005, 2006 Joris Vink <joris@openbsd.org>
* Copyright (c) 2006 Xavier Santolaria <xsa@openbsd.org>
#include <err.h>
#include <fcntl.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <unistd.h>
if (strlcpy(out, rcspath, len) >= len)
errx(1, "rcs_choosefile; truncation");
- xfree(suffixes);
+ free(suffixes);
return (fd);
}
if (strlcpy(out, fpath, len) >= len)
errx(1, "rcs_choosefile: truncation");
- xfree(suffixes);
+ free(suffixes);
return (fd);
}
if (strlcat(rcspath, suffixes, sizeof(rcspath)) >= sizeof(rcspath))
errx(1, "rcs_choosefile: truncation");
- xfree(suffixes);
+ free(suffixes);
if (strlcpy(out, rcspath, len) >= len)
errx(1, "rcs_choosefile: truncation");
}
rcs_argv_destroy(revargv);
- if (lnum.rn_id != NULL)
- xfree(lnum.rn_id);
- if (rnum.rn_id != NULL)
- xfree(rnum.rn_id);
+ free(lnum.rn_id);
+ free(rnum.rn_id);
return (nrev);
}
content = rcs_prompt(prompt);
rcs_desc_set(file, content);
- xfree(content);
+ free(content);
return (0);
}
while ((lp = TAILQ_FIRST(&(lines->l_lines))) != NULL) {
TAILQ_REMOVE(&(lines->l_lines), lp, l_list);
- xfree(lp);
+ free(lp);
}
- xfree(lines);
+ free(lines);
}
BUF *
void
rcs_argv_destroy(struct rcs_argvector *av)
{
- xfree(av->str);
- xfree(av->argv);
- xfree(av);
+ free(av->str);
+ free(av->argv);
+ free(av);
}
/*
break;
}
}
- xfree(suffixes);
+ free(suffixes);
}
}
-/* $OpenBSD: worklist.c,v 1.3 2010/07/23 08:31:19 ray Exp $ */
+/* $OpenBSD: worklist.c,v 1.4 2015/06/13 20:15:21 nicm Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
* All rights reserved.
#include <err.h>
#include <signal.h>
+#include <stdlib.h>
#include <string.h>
#include <unistd.h>
while ((wkl = SLIST_FIRST(list)) != NULL) {
SLIST_REMOVE_HEAD(list, wkl_list);
- xfree(wkl);
+ free(wkl);
}
sigprocmask(SIG_SETMASK, &old, NULL);
-/* $OpenBSD: xmalloc.c,v 1.8 2015/03/26 15:17:30 okan Exp $ */
+/* $OpenBSD: xmalloc.c,v 1.9 2015/06/13 20:15:21 nicm Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
return new_ptr;
}
-void
-xfree(void *ptr)
-{
- if (ptr == NULL)
- errx(1, "xfree: NULL pointer given as argument");
- free(ptr);
-}
-
char *
xstrdup(const char *str)
{
-/* $OpenBSD: xmalloc.h,v 1.2 2014/12/01 21:58:46 deraadt Exp $ */
+/* $OpenBSD: xmalloc.h,v 1.3 2015/06/13 20:15:21 nicm Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
void *xmalloc(size_t);
void *xcalloc(size_t, size_t);
void *xreallocarray(void *, size_t, size_t);
-void xfree(void *);
char *xstrdup(const char *);
int xasprintf(char **, const char *, ...)
__attribute__((__format__ (printf, 2, 3)))