summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>2015-04-01 22:24:02 +0000
committermillert <millert@openbsd.org>2015-04-01 22:24:02 +0000
commitde2b9554e7f861bdf604bbd7efe24dcbe27a4aef (patch)
treee8944c2aef3d5b47253ea5bf843171ec53f7670d
parentRevert unintentional commit. This will be revisited shortly. (diff)
downloadwireguard-openbsd-de2b9554e7f861bdf604bbd7efe24dcbe27a4aef.tar.xz
wireguard-openbsd-de2b9554e7f861bdf604bbd7efe24dcbe27a4aef.zip
Just use sort_reallocarray() everywhere.
-rw-r--r--usr.bin/sort/file.c6
-rw-r--r--usr.bin/sort/mem.c13
-rw-r--r--usr.bin/sort/mem.h3
-rw-r--r--usr.bin/sort/sort.c4
4 files changed, 7 insertions, 19 deletions
diff --git a/usr.bin/sort/file.c b/usr.bin/sort/file.c
index 71dd40e02ce..b97d5a76ffd 100644
--- a/usr.bin/sort/file.c
+++ b/usr.bin/sort/file.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: file.c,v 1.12 2015/04/01 21:33:01 millert Exp $ */
+/* $OpenBSD: file.c,v 1.13 2015/04/01 22:24:02 millert Exp $ */
/*-
* Copyright (C) 2009 Gabor Kovesdan <gabor@FreeBSD.org>
@@ -664,8 +664,8 @@ file_reader_readline(struct file_reader *fr)
if (remsz > (READ_CHUNK >> 1)) {
search_start = fr->cbsz - fr->strbeg;
fr->cbsz += READ_CHUNK;
- fr->buffer = sort_realloc(fr->buffer,
- fr->cbsz);
+ fr->buffer = sort_reallocarray(fr->buffer,
+ 1, fr->cbsz);
bsz1 = fread(fr->buffer + fr->bsz, 1,
READ_CHUNK, fr->file);
if (bsz1 == 0) {
diff --git a/usr.bin/sort/mem.c b/usr.bin/sort/mem.c
index 17f9af0633a..03416fe0cf3 100644
--- a/usr.bin/sort/mem.c
+++ b/usr.bin/sort/mem.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mem.c,v 1.4 2015/04/01 20:58:13 millert Exp $ */
+/* $OpenBSD: mem.c,v 1.5 2015/04/01 22:24:02 millert Exp $ */
/*-
* Copyright (C) 2009 Gabor Kovesdan <gabor@FreeBSD.org>
@@ -70,17 +70,6 @@ sort_free(void *ptr)
}
/*
- * realloc() wrapper.
- */
-void *
-sort_realloc(void *ptr, size_t size)
-{
- if ((ptr = realloc(ptr, size)) == NULL)
- err(2, NULL);
- return ptr;
-}
-
-/*
* reallocarray() wrapper.
*/
void *
diff --git a/usr.bin/sort/mem.h b/usr.bin/sort/mem.h
index 48014787511..14627c90904 100644
--- a/usr.bin/sort/mem.h
+++ b/usr.bin/sort/mem.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: mem.h,v 1.3 2015/03/30 19:57:36 millert Exp $ */
+/* $OpenBSD: mem.h,v 1.4 2015/04/01 22:24:02 millert Exp $ */
/*-
* Copyright (C) 2009 Gabor Kovesdan <gabor@FreeBSD.org>
@@ -41,7 +41,6 @@
void *sort_calloc(size_t nmemb, size_t size);
void *sort_malloc(size_t);
void sort_free(void *ptr);
-void *sort_realloc(void *, size_t);
void *sort_reallocarray(void *, size_t, size_t);
char *sort_strdup(const char *);
int sort_asprintf(char **, const char *, ...);
diff --git a/usr.bin/sort/sort.c b/usr.bin/sort/sort.c
index 284c680d3e7..184252c9dab 100644
--- a/usr.bin/sort/sort.c
+++ b/usr.bin/sort/sort.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sort.c,v 1.66 2015/04/01 21:45:50 millert Exp $ */
+/* $OpenBSD: sort.c,v 1.67 2015/04/01 22:24:02 millert Exp $ */
/*-
* Copyright (C) 2009 Gabor Kovesdan <gabor@FreeBSD.org>
@@ -1018,7 +1018,7 @@ main(int argc, char *argv[])
if (keys_num == 0) {
keys_num = 1;
- keys = sort_realloc(keys, sizeof(struct key_specs));
+ keys = sort_reallocarray(keys, 1, sizeof(struct key_specs));
memset(&(keys[0]), 0, sizeof(struct key_specs));
keys[0].c1 = 1;
keys[0].pos1b = default_sort_mods->bflag;