summaryrefslogtreecommitdiff
path: root/lib/libc/stdlib
diff options
context:
space:
mode:
authornia <nia@NetBSD.org>2022-03-12 08:26:01 +0000
committernia <nia@NetBSD.org>2022-03-12 08:26:01 +0000
commit35aaece3827dc4c1e8151eca96d2c107344aaa0e (patch)
tree46f5d378b81441084123e2aecb93ae159fcdf49c /lib/libc/stdlib
parenteda29d51e6aabd304b59ff3e977e0467fd33bd9f (diff)
hcreate(3): use reallocarr instead of malloc(x * y)
Diffstat (limited to 'lib/libc/stdlib')
-rw-r--r--lib/libc/stdlib/hcreate.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/libc/stdlib/hcreate.c b/lib/libc/stdlib/hcreate.c
index cab145d13b7..ba32e5a6e00 100644
--- a/lib/libc/stdlib/hcreate.c
+++ b/lib/libc/stdlib/hcreate.c
@@ -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 @@ hcreate_r(size_t nel, struct hsearch_data *head)
/* 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;
}