Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libc/stdlib radixsort(3): use reallocarr instead of mall...
details: https://anonhg.NetBSD.org/src/rev/b661db6d541e
branches: trunk
changeset: 990498:b661db6d541e
user: nia <nia%NetBSD.org@localhost>
date: Fri Oct 29 10:29:51 2021 +0000
description:
radixsort(3): use reallocarr instead of malloc(x * y)
diffstat:
lib/libc/stdlib/radixsort.c | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diffs (28 lines):
diff -r 1bce8835df30 -r b661db6d541e lib/libc/stdlib/radixsort.c
--- a/lib/libc/stdlib/radixsort.c Fri Oct 29 10:26:10 2021 +0000
+++ b/lib/libc/stdlib/radixsort.c Fri Oct 29 10:29:51 2021 +0000
@@ -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 @@
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);
Home |
Main Index |
Thread Index |
Old Index