summaryrefslogtreecommitdiff
path: root/toke.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2007-10-16 09:48:48 +0000
committerNicholas Clark <nick@ccl4.org>2007-10-16 09:48:48 +0000
commit4a731d7b697551fe227bb3efe87565699446d220 (patch)
treecfc1a6e72b31b00cd861e2384abde9d234fd4eef /toke.c
parent5686ee583d95bf194b657486beb96283ecfc182b (diff)
downloadperl-4a731d7b697551fe227bb3efe87565699446d220.tar.gz
Given that S_feature_is_enabled() is a static function, we can know all
the possible strings that can be passed to it, and their lengths. So we can avoid my_strlcpy() and instead use memcpy(). Brought to you by the Campaign for the Elimination of strlen(). p4raw-id: //depot/perl@32114
Diffstat (limited to 'toke.c')
-rw-r--r--toke.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/toke.c b/toke.c
index 48340f9eb9..eb785cc35e 100644
--- a/toke.c
+++ b/toke.c
@@ -559,6 +559,9 @@ S_missingterm(pTHX_ char *s)
#define FEATURE_IS_ENABLED(name) \
((0 != (PL_hints & HINT_LOCALIZE_HH)) \
&& S_feature_is_enabled(aTHX_ STR_WITH_LEN(name)))
+/* The longest string we pass in. */
+#define MAX_FEATURE_LEN (sizeof("switch")-1)
+
/*
* S_feature_is_enabled
* Check whether the named feature is enabled.
@@ -568,8 +571,9 @@ S_feature_is_enabled(pTHX_ const char *name, STRLEN namelen)
{
dVAR;
HV * const hinthv = GvHV(PL_hintgv);
- char he_name[32] = "feature_";
- (void) my_strlcpy(&he_name[8], name, 24);
+ char he_name[8 + MAX_FEATURE_LEN] = "feature_";
+ assert(namelen <= MAX_FEATURE_LEN);
+ memcpy(&he_name[8], name, namelen);
return (hinthv && hv_exists(hinthv, he_name, 8 + namelen));
}