Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libc/stdlib hcreate(3): use reallocarr instead of malloc...
details: https://anonhg.NetBSD.org/src/rev/0aef19fcc525
branches: trunk
changeset: 363419:0aef19fcc525
user: nia <nia%NetBSD.org@localhost>
date: Sat Mar 12 08:26:01 2022 +0000
description:
hcreate(3): use reallocarr instead of malloc(x * y)
diffstat:
lib/libc/stdlib/hcreate.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diffs (29 lines):
diff -r 198f875c8e21 -r 0aef19fcc525 lib/libc/stdlib/hcreate.c
--- a/lib/libc/stdlib/hcreate.c Fri Mar 11 16:24:22 2022 +0000
+++ b/lib/libc/stdlib/hcreate.c Sat Mar 12 08:26:01 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hcreate.c,v 1.10 2014/07/20 20:17:21 christos Exp $ */
+/* $NetBSD: hcreate.c,v 1.11 2022/03/12 08:26:01 nia Exp $ */
/*
* Copyright (c) 2001 Christopher G. Demetriou
@@ -43,7 +43,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: hcreate.c,v 1.10 2014/07/20 20:17:21 christos Exp $");
+__RCSID("$NetBSD: hcreate.c,v 1.11 2022/03/12 08:26:01 nia Exp $");
#endif /* LIBC_SCCS and not lint */
#if !defined(lint)
@@ -125,8 +125,8 @@
/* Allocate the table. */
head->size = nel;
head->filled = 0;
- p = malloc(nel * sizeof table[0]);
- if (p == NULL) {
+ p = NULL;
+ if (reallocarr(&p, nel, sizeof(table[0])) != 0) {
errno = ENOMEM;
return 0;
}
Home |
Main Index |
Thread Index |
Old Index