diff options
| author | nia <nia@NetBSD.org> | 2021-10-29 10:29:51 +0000 |
|---|---|---|
| committer | nia <nia@NetBSD.org> | 2021-10-29 10:29:51 +0000 |
| commit | 7d5a7934dde5e3cd4e80a643d021ef71bcdc17a1 (patch) | |
| tree | a9849b880713ccc1876a0ff5003a2894bf10c7a9 /lib/libc/stdlib | |
| parent | 4ff3b98807a7f275878dd0f09371d42b40d0867b (diff) | |
radixsort(3): use reallocarr instead of malloc(x * y)
Diffstat (limited to 'lib/libc/stdlib')
| -rw-r--r-- | lib/libc/stdlib/radixsort.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/libc/stdlib/radixsort.c b/lib/libc/stdlib/radixsort.c index e8435f5f2e4..db8a7eb3936 100644 --- a/lib/libc/stdlib/radixsort.c +++ b/lib/libc/stdlib/radixsort.c @@ -1,4 +1,4 @@ -/* $NetBSD: radixsort.c,v 1.19 2009/09/05 08:53:06 dsl Exp $ */ +/* $NetBSD: radixsort.c,v 1.20 2021/10/29 10:29:51 nia Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)radixsort.c 8.2 (Berkeley) 4/28/95"; #else -__RCSID("$NetBSD: radixsort.c,v 1.19 2009/09/05 08:53:06 dsl Exp $"); +__RCSID("$NetBSD: radixsort.c,v 1.20 2021/10/29 10:29:51 nia Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -129,7 +129,8 @@ sradixsort(const u_char **a, int n, const u_char *tab, u_int endch) if (n < THRESHOLD) simplesort(a, n, 0, tr, endch); else { - if ((ta = malloc(n * sizeof(a))) == NULL) + ta = NULL; + if (reallocarr(&ta, n, sizeof(a)) != 0) return (-1); r_sort_b(a, ta, n, 0, tr, endch); free(ta); |
