summaryrefslogtreecommitdiff
path: root/usr.bin/make/make_malloc.h
diff options
context:
space:
mode:
authorrillig <rillig@NetBSD.org>2020-08-20 06:35:14 +0000
committerrillig <rillig@NetBSD.org>2020-08-20 06:35:14 +0000
commit85ff1f3f95c9e3628312b799a7d889604bfdb8e9 (patch)
tree0028d4c80dc847068e1e14fc7e095b4d511dc3de /usr.bin/make/make_malloc.h
parentb01a3dadfd0c9e1e7793824ec750da8bdbd95bc4 (diff)
make(1): remove unreached code from bmake_strndup
The "at most" branch was never taken since all call sites in var.c only ever need a substring, and the target buffer is not limited. Therefore rename the function and make it simpler. It's ok that bmake_strldup is defined as estrndup in case of USE_EMALLOC since that function's implementation is compatible to the "copy exactly", it just contains some extra null checks that will never match since the variable values cannot (well, or should not) contain null bytes. Theoretically they can, but the behavior then depends on the exact implementation and is unreliable, therefore nobody does this. After all, Makefiles are used for text processing, not for binary data.
Diffstat (limited to 'usr.bin/make/make_malloc.h')
-rw-r--r--usr.bin/make/make_malloc.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/usr.bin/make/make_malloc.h b/usr.bin/make/make_malloc.h
index 8afc8bddd50..fa35cca8c08 100644
--- a/usr.bin/make/make_malloc.h
+++ b/usr.bin/make/make_malloc.h
@@ -1,4 +1,4 @@
-/* $NetBSD: make_malloc.h,v 1.6 2020/08/01 14:47:49 rillig Exp $ */
+/* $NetBSD: make_malloc.h,v 1.7 2020/08/20 06:35:14 rillig Exp $ */
/*-
* Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -30,13 +30,13 @@
void *bmake_malloc(size_t);
void *bmake_realloc(void *, size_t);
char *bmake_strdup(const char *);
-char *bmake_strndup(const char *, size_t);
+char *bmake_strldup(const char *, size_t);
#else
#include <util.h>
#define bmake_malloc(x) emalloc(x)
#define bmake_realloc(x,y) erealloc(x,y)
#define bmake_strdup(x) estrdup(x)
-#define bmake_strndup(x,y) estrndup(x,y)
+#define bmake_strldup(x,y) estrndup(x,y)
#endif
/* Thin wrapper around free(3) to avoid the extra function call in case