-/* $OpenBSD: diff.c,v 1.58 2015/01/16 06:40:07 deraadt Exp $ */
+/* $OpenBSD: diff.c,v 1.59 2015/04/29 04:00:25 deraadt Exp $ */
/*
* Copyright (c) 2003 Todd C. Miller <Todd.Miller@courtesan.com>
else {
/* old + "|" + new + NUL */
len = strlen(ignore_pats) + strlen(pattern) + 2;
- ignore_pats = xrealloc(ignore_pats, 1, len);
+ ignore_pats = xreallocarray(ignore_pats, 1, len);
strlcat(ignore_pats, "|", len);
strlcat(ignore_pats, pattern, len);
}
-/* $OpenBSD: diffreg.c,v 1.85 2015/02/05 12:59:57 millert Exp $ */
+/* $OpenBSD: diffreg.c,v 1.86 2015/04/29 04:00:25 deraadt Exp $ */
/*
* Copyright (C) Caldera International Inc. 2001-2002.
member = (int *)file[1];
equiv(sfile[0], slen[0], sfile[1], slen[1], member);
- member = xrealloc(member, slen[1] + 2, sizeof(*member));
+ member = xreallocarray(member, slen[1] + 2, sizeof(*member));
class = (int *)file[0];
unsort(sfile[0], slen[0], class);
- class = xrealloc(class, slen[0] + 2, sizeof(*class));
+ class = xreallocarray(class, slen[0] + 2, sizeof(*class));
klist = xcalloc(slen[0] + 2, sizeof(*klist));
clen = 0;
xfree(member);
xfree(class);
- J = xrealloc(J, len[0] + 2, sizeof(*J));
+ J = xreallocarray(J, len[0] + 2, sizeof(*J));
unravel(klist[i]);
xfree(clist);
xfree(klist);
- ixold = xrealloc(ixold, len[0] + 2, sizeof(*ixold));
- ixnew = xrealloc(ixnew, len[1] + 2, sizeof(*ixnew));
+ ixold = xreallocarray(ixold, len[0] + 2, sizeof(*ixold));
+ ixnew = xreallocarray(ixnew, len[1] + 2, sizeof(*ixnew));
check(f1, f2, flags);
output(file1, f1, file2, f2, flags);
if (ostdout != -1) {
for (j = 0; (h = readhash(fd, flags));) {
if (j == sz) {
sz = sz * 3 / 2;
- p = xrealloc(p, sz + 3, sizeof(*p));
+ p = xreallocarray(p, sz + 3, sizeof(*p));
}
p[++j].value = h;
}
if (clen == clistlen) {
clistlen = clistlen * 11 / 10;
- clist = xrealloc(clist, clistlen, sizeof(*clist));
+ clist = xreallocarray(clist, clistlen, sizeof(*clist));
}
q = clist + clen;
q->x = x;
if (context_vec_ptr == context_vec_end - 1) {
ptrdiff_t offset = context_vec_ptr - context_vec_start;
max_context <<= 1;
- context_vec_start = xrealloc(context_vec_start,
+ context_vec_start = xreallocarray(context_vec_start,
max_context, sizeof(*context_vec_start));
context_vec_end = context_vec_start + max_context;
context_vec_ptr = context_vec_start + offset;
-/* $OpenBSD: xmalloc.c,v 1.5 2015/02/05 12:59:57 millert Exp $ */
+/* $OpenBSD: xmalloc.c,v 1.6 2015/04/29 04:00:25 deraadt Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
}
void *
-xrealloc(void *ptr, size_t nmemb, size_t size)
+xreallocarray(void *ptr, size_t nmemb, size_t size)
{
void *new_ptr;
- size_t new_size = nmemb * size;
- if (new_size == 0)
- errx(2, "xrealloc: zero size");
- if (SIZE_MAX / nmemb < size)
- errx(2, "xrealloc: nmemb * size > SIZE_MAX");
- if (ptr == NULL)
- new_ptr = malloc(new_size);
- else
- new_ptr = realloc(ptr, new_size);
+ new_ptr = reallocarray(ptr, nmemb, size);
if (new_ptr == NULL)
err(2, NULL);
return new_ptr;
-/* $OpenBSD: xmalloc.h,v 1.2 2009/06/07 08:39:13 ray Exp $ */
+/* $OpenBSD: xmalloc.h,v 1.3 2015/04/29 04:00:25 deraadt Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
void *xmalloc(size_t);
void *xcalloc(size_t, size_t);
-void *xrealloc(void *, size_t, size_t);
+void *xreallocarray(void *, size_t, size_t);
void xfree(void *);
char *xstrdup(const char *);
int xasprintf(char **, const char *, ...)