-/* * $OpenBSD: extern.h,v 1.18 2012/12/05 23:20:25 deraadt Exp $*/
+/* * $OpenBSD: extern.h,v 1.19 2014/05/18 08:10:00 espie Exp $*/
/*-
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
*/
void brace_subst(char *, char **, char *, int);
-void *emalloc(unsigned int);
+void *emalloc(size_t);
+void *ereallocarray(void *, size_t, size_t);
PLAN *find_create(char ***);
int find_execute(PLAN *, char **);
PLAN *find_formplan(char **);
-/* $OpenBSD: function.c,v 1.40 2013/04/20 04:52:24 deraadt Exp $ */
+/* $OpenBSD: function.c,v 1.41 2014/05/18 08:10:00 espie Exp $ */
/*-
* Copyright (c) 1990, 1993
cnt = ap - *argvp - 1; /* units are words */
new->ep_maxargs = 5000;
- new->e_argv = (char **)emalloc((u_int)(cnt + new->ep_maxargs)
- * sizeof(char **));
+ new->e_argv = ereallocarray(NULL,
+ (size_t)(cnt + new->ep_maxargs), sizeof(char **));
/* We start stuffing arguments after the user's last one. */
new->ep_bxp = &new->e_argv[cnt];
new->ep_rval = 0;
} else { /* !F_PLUSSET */
cnt = ap - *argvp + 1;
- new->e_argv = (char **)emalloc((u_int)cnt * sizeof(char *));
- new->e_orig = (char **)emalloc((u_int)cnt * sizeof(char *));
- new->e_len = (int *)emalloc((u_int)cnt * sizeof(int));
+ new->e_argv = ereallocarray(NULL, cnt, sizeof(char *));
+ new->e_orig = ereallocarray(NULL, cnt, sizeof(char *));
+ new->e_len = ereallocarray(NULL, cnt, sizeof(int));
for (argv = *argvp, cnt = 0; argv < ap; ++argv, ++cnt) {
new->e_orig[cnt] = *argv;
}
cnt = ap - *argvp + 1;
- new->e_argv = (char **)emalloc((u_int)cnt * sizeof(char *));
- new->e_orig = (char **)emalloc((u_int)cnt * sizeof(char *));
- new->e_len = (int *)emalloc((u_int)cnt * sizeof(int));
+ new->e_argv = ereallocarray(NULL, cnt, sizeof(char *));
+ new->e_orig = ereallocarray(NULL, cnt, sizeof(char *));
+ new->e_len = ereallocarray(NULL, cnt, sizeof(int));
for (argv = *argvp, cnt = 0; argv < ap; ++argv, ++cnt) {
new->e_orig[cnt] = *argv;
-/* $OpenBSD: main.c,v 1.29 2013/11/15 22:20:04 millert Exp $ */
+/* $OpenBSD: main.c,v 1.30 2014/05/18 08:10:00 espie Exp $ */
/*-
* Copyright (c) 1990, 1993
(void)time(&now); /* initialize the time-of-day */
- p = paths = (char **) emalloc(sizeof(char *) * argc);
+ p = paths = ereallocarray(NULL, argc, sizeof(char *));
sigaction(SIGINFO, &sa, NULL);
usage();
*p = NULL;
- if (!(paths2 = realloc(paths, sizeof(char *) * (p - paths + 1))))
+ if (!(paths2 = reallocarray(paths, p - paths + 1, sizeof(char *))))
err(1, NULL);
paths = paths2;
-/* $OpenBSD: misc.c,v 1.11 2009/10/27 23:59:38 deraadt Exp $ */
+/* $OpenBSD: misc.c,v 1.12 2014/05/18 08:10:00 espie Exp $ */
/*-
* Copyright (c) 1990, 1993
* malloc with error checking.
*/
void *
-emalloc(u_int len)
+emalloc(size_t len)
{
void *p;
err(1, NULL);
}
+void *
+ereallocarray(void *oldp, size_t sz1, size_t sz2)
+{
+ void *p;
+
+ if ((p = reallocarray(oldp, sz1, sz2)) != NULL)
+ return (p);
+ err(1, NULL);
+}
+
/*
* show_path --
* called on SIGINFO