summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2007-01-26 16:16:29 +0000
committerNicholas Clark <nick@ccl4.org>2007-01-26 16:16:29 +0000
commitd9095cec1bba87df718f5a1d0a9ab42fe217cea4 (patch)
treec9fa8049db941c9278d890ee93ab5c93553b70d7 /util.c
parentabf8b121784743d34fc5407ef35129d1bbdffb2d (diff)
downloadperl-d9095cec1bba87df718f5a1d0a9ab42fe217cea4.tar.gz
Stop S_incline needing to temporarily write a '\0' into its passed-in
buffer. (Requires adding gv_fetchfile_flags(), savesharedpvn() and CopFILE_setn() to provide pointer/length versions of APIs) p4raw-id: //depot/perl@30015
Diffstat (limited to 'util.c')
-rw-r--r--util.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/util.c b/util.c
index 69595228e5..1e85ecaca7 100644
--- a/util.c
+++ b/util.c
@@ -953,6 +953,27 @@ Perl_savesharedpv(pTHX_ const char *pv)
}
/*
+=for apidoc savesharedpvn
+
+A version of C<savepvn()> which allocates the duplicate string in memory
+which is shared between threads. (With the specific difference that a NULL
+pointer is not acceptable)
+
+=cut
+*/
+char *
+Perl_savesharedpvn(pTHX_ const char *const pv, const STRLEN len)
+{
+ char *const newaddr = (char*)PerlMemShared_malloc(len + 1);
+ assert(pv);
+ if (!newaddr) {
+ return write_no_mem();
+ }
+ newaddr[len] = '\0';
+ return (char*)memcpy(newaddr, pv, len);
+}
+
+/*
=for apidoc savesvpv
A version of C<savepv()>/C<savepvn()> which gets the string to duplicate from