diff options
author | Nicholas Clark <nick@ccl4.org> | 2007-01-26 16:16:29 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2007-01-26 16:16:29 +0000 |
commit | d9095cec1bba87df718f5a1d0a9ab42fe217cea4 (patch) | |
tree | c9fa8049db941c9278d890ee93ab5c93553b70d7 /util.c | |
parent | abf8b121784743d34fc5407ef35129d1bbdffb2d (diff) | |
download | perl-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.c | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -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 |