summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--embed.fnc8
-rw-r--r--inline.h118
-rw-r--r--proto.h8
-rw-r--r--util.c118
4 files changed, 126 insertions, 126 deletions
diff --git a/embed.fnc b/embed.fnc
index 91a567ee2c..d4c6b5850b 100644
--- a/embed.fnc
+++ b/embed.fnc
@@ -1715,8 +1715,8 @@ p |void |rxres_save |NN void **rsp|NN REGEXP *rx
: Used in pp_sys.c
p |I32 |same_dirent |NN const char* a|NN const char* b
#endif
-Apda |char* |savepv |NULLOK const char* pv
-Apda |char* |savepvn |NULLOK const char* pv|Size_t len
+Asda |char* |savepv |NULLOK const char* pv
+Asda |char* |savepvn |NULLOK const char* pv|Size_t len
Apda |char* |savesharedpv |NULLOK const char* pv
: NULLOK only to suppress a compiler warning
@@ -1726,8 +1726,8 @@ Apda |char* |rcpv_new |NULLOK const char *const pv \
|STRLEN len|U32 flags
Apd |char* |rcpv_copy |NULLOK char *const pv
Apd |char* |rcpv_free |NULLOK char *const pv
-Apda |char* |savesharedsvpv |NN SV *sv
-Apda |char* |savesvpv |NN SV* sv
+Asda |char* |savesharedsvpv |NN SV *sv
+Asda |char* |savesvpv |NN SV* sv
Cp |void |savestack_grow
Cp |void |savestack_grow_cnt |I32 need
Amd |void |save_aelem |NN AV* av|SSize_t idx|NN SV **sptr
diff --git a/inline.h b/inline.h
index 0995d4aace..49cae2738b 100644
--- a/inline.h
+++ b/inline.h
@@ -3506,6 +3506,124 @@ Perl_padname_refcnt_inc(PADNAME *pn)
return pn;
}
+/* copy a string to a safe spot */
+
+/*
+=for apidoc_section $string
+=for apidoc savepv
+
+Perl's version of C<strdup()>. Returns a pointer to a newly allocated
+string which is a duplicate of C<pv>. The size of the string is
+determined by C<strlen()>, which means it may not contain embedded C<NUL>
+characters and must have a trailing C<NUL>. To prevent memory leaks, the
+memory allocated for the new string needs to be freed when no longer needed.
+This can be done with the C<L</Safefree>> function, or
+L<C<SAVEFREEPV>|perlguts/SAVEFREEPV(p)>.
+
+On some platforms, Windows for example, all allocated memory owned by a thread
+is deallocated when that thread ends. So if you need that not to happen, you
+need to use the shared memory functions, such as C<L</savesharedpv>>.
+
+=cut
+*/
+
+PERL_STATIC_INLINE char *
+Perl_savepv(pTHX_ const char *pv)
+{
+ PERL_UNUSED_CONTEXT;
+ if (!pv)
+ return NULL;
+ else {
+ char *newaddr;
+ const STRLEN pvlen = strlen(pv)+1;
+ Newx(newaddr, pvlen, char);
+ return (char*)memcpy(newaddr, pv, pvlen);
+ }
+}
+
+/* same thing but with a known length */
+
+/*
+=for apidoc savepvn
+
+Perl's version of what C<strndup()> would be if it existed. Returns a
+pointer to a newly allocated string which is a duplicate of the first
+C<len> bytes from C<pv>, plus a trailing
+C<NUL> byte. The memory allocated for
+the new string can be freed with the C<Safefree()> function.
+
+On some platforms, Windows for example, all allocated memory owned by a thread
+is deallocated when that thread ends. So if you need that not to happen, you
+need to use the shared memory functions, such as C<L</savesharedpvn>>.
+
+=cut
+*/
+
+PERL_STATIC_INLINE char *
+Perl_savepvn(pTHX_ const char *pv, Size_t len)
+{
+ char *newaddr;
+ PERL_UNUSED_CONTEXT;
+
+ Newx(newaddr,len+1,char);
+ /* Give a meaning to NULL pointer mainly for the use in sv_magic() */
+ if (pv) {
+ /* might not be null terminated */
+ newaddr[len] = '\0';
+ return (char *) CopyD(pv,newaddr,len,char);
+ }
+ else {
+ return (char *) ZeroD(newaddr,len+1,char);
+ }
+}
+
+/*
+=for apidoc savesvpv
+
+A version of C<savepv()>/C<savepvn()> which gets the string to duplicate from
+the passed in SV using C<SvPV()>
+
+On some platforms, Windows for example, all allocated memory owned by a thread
+is deallocated when that thread ends. So if you need that not to happen, you
+need to use the shared memory functions, such as C<L</savesharedsvpv>>.
+
+=cut
+*/
+
+PERL_STATIC_INLINE char *
+Perl_savesvpv(pTHX_ SV *sv)
+{
+ STRLEN len;
+ const char * const pv = SvPV_const(sv, len);
+ char *newaddr;
+
+ PERL_ARGS_ASSERT_SAVESVPV;
+
+ ++len;
+ Newx(newaddr,len,char);
+ return (char *) CopyD(pv,newaddr,len,char);
+}
+
+/*
+=for apidoc savesharedsvpv
+
+A version of C<savesharedpv()> which allocates the duplicate string in
+memory which is shared between threads.
+
+=cut
+*/
+
+PERL_STATIC_INLINE char *
+Perl_savesharedsvpv(pTHX_ SV *sv)
+{
+ STRLEN len;
+ const char * const pv = SvPV_const(sv, len);
+
+ PERL_ARGS_ASSERT_SAVESHAREDSVPV;
+
+ return savesharedpvn(pv, len);
+}
+
/*
* ex: set ts=8 sts=4 sw=4 et:
*/
diff --git a/proto.h b/proto.h
index fab3b51c84..a0c5f497f6 100644
--- a/proto.h
+++ b/proto.h
@@ -3598,12 +3598,12 @@ PERL_CALLCONV SV* Perl_save_svref(pTHX_ SV** sptr);
PERL_CALLCONV void Perl_save_vptr(pTHX_ void *ptr);
#define PERL_ARGS_ASSERT_SAVE_VPTR \
assert(ptr)
-PERL_CALLCONV char* Perl_savepv(pTHX_ const char* pv)
+STATIC char* Perl_savepv(pTHX_ const char* pv)
__attribute__malloc__
__attribute__warn_unused_result__;
#define PERL_ARGS_ASSERT_SAVEPV
-PERL_CALLCONV char* Perl_savepvn(pTHX_ const char* pv, Size_t len)
+STATIC char* Perl_savepvn(pTHX_ const char* pv, Size_t len)
__attribute__malloc__
__attribute__warn_unused_result__;
#define PERL_ARGS_ASSERT_SAVEPVN
@@ -3618,7 +3618,7 @@ PERL_CALLCONV char* Perl_savesharedpvn(pTHX_ const char *const pv, const STRLEN
__attribute__warn_unused_result__;
#define PERL_ARGS_ASSERT_SAVESHAREDPVN
-PERL_CALLCONV char* Perl_savesharedsvpv(pTHX_ SV *sv)
+STATIC char* Perl_savesharedsvpv(pTHX_ SV *sv)
__attribute__malloc__
__attribute__warn_unused_result__;
#define PERL_ARGS_ASSERT_SAVESHAREDSVPV \
@@ -3628,7 +3628,7 @@ PERL_CALLCONV void Perl_savestack_grow(pTHX);
#define PERL_ARGS_ASSERT_SAVESTACK_GROW
PERL_CALLCONV void Perl_savestack_grow_cnt(pTHX_ I32 need);
#define PERL_ARGS_ASSERT_SAVESTACK_GROW_CNT
-PERL_CALLCONV char* Perl_savesvpv(pTHX_ SV* sv)
+STATIC char* Perl_savesvpv(pTHX_ SV* sv)
__attribute__malloc__
__attribute__warn_unused_result__;
#define PERL_ARGS_ASSERT_SAVESVPV \
diff --git a/util.c b/util.c
index b0bf189ca1..8da7c11fa7 100644
--- a/util.c
+++ b/util.c
@@ -1319,77 +1319,6 @@ Perl_cntrl_to_mnemonic(const U8 c)
return NULL;
}
-/* copy a string to a safe spot */
-
-/*
-=for apidoc_section $string
-=for apidoc savepv
-
-Perl's version of C<strdup()>. Returns a pointer to a newly allocated
-string which is a duplicate of C<pv>. The size of the string is
-determined by C<strlen()>, which means it may not contain embedded C<NUL>
-characters and must have a trailing C<NUL>. To prevent memory leaks, the
-memory allocated for the new string needs to be freed when no longer needed.
-This can be done with the C<L</Safefree>> function, or
-L<C<SAVEFREEPV>|perlguts/SAVEFREEPV(p)>.
-
-On some platforms, Windows for example, all allocated memory owned by a thread
-is deallocated when that thread ends. So if you need that not to happen, you
-need to use the shared memory functions, such as C<L</savesharedpv>>.
-
-=cut
-*/
-
-char *
-Perl_savepv(pTHX_ const char *pv)
-{
- PERL_UNUSED_CONTEXT;
- if (!pv)
- return NULL;
- else {
- char *newaddr;
- const STRLEN pvlen = strlen(pv)+1;
- Newx(newaddr, pvlen, char);
- return (char*)memcpy(newaddr, pv, pvlen);
- }
-}
-
-/* same thing but with a known length */
-
-/*
-=for apidoc savepvn
-
-Perl's version of what C<strndup()> would be if it existed. Returns a
-pointer to a newly allocated string which is a duplicate of the first
-C<len> bytes from C<pv>, plus a trailing
-C<NUL> byte. The memory allocated for
-the new string can be freed with the C<Safefree()> function.
-
-On some platforms, Windows for example, all allocated memory owned by a thread
-is deallocated when that thread ends. So if you need that not to happen, you
-need to use the shared memory functions, such as C<L</savesharedpvn>>.
-
-=cut
-*/
-
-char *
-Perl_savepvn(pTHX_ const char *pv, Size_t len)
-{
- char *newaddr;
- PERL_UNUSED_CONTEXT;
-
- Newx(newaddr,len+1,char);
- /* Give a meaning to NULL pointer mainly for the use in sv_magic() */
- if (pv) {
- /* might not be null terminated */
- newaddr[len] = '\0';
- return (char *) CopyD(pv,newaddr,len,char);
- }
- else {
- return (char *) ZeroD(newaddr,len+1,char);
- }
-}
-
/*
=for apidoc savesharedpv
@@ -1441,53 +1370,6 @@ Perl_savesharedpvn(pTHX_ const char *const pv, const STRLEN len)
return (char*)memcpy(newaddr, pv, len);
}
-/*
-=for apidoc savesvpv
-
-A version of C<savepv()>/C<savepvn()> which gets the string to duplicate from
-the passed in SV using C<SvPV()>
-
-On some platforms, Windows for example, all allocated memory owned by a thread
-is deallocated when that thread ends. So if you need that not to happen, you
-need to use the shared memory functions, such as C<L</savesharedsvpv>>.
-
-=cut
-*/
-
-char *
-Perl_savesvpv(pTHX_ SV *sv)
-{
- STRLEN len;
- const char * const pv = SvPV_const(sv, len);
- char *newaddr;
-
- PERL_ARGS_ASSERT_SAVESVPV;
-
- ++len;
- Newx(newaddr,len,char);
- return (char *) CopyD(pv,newaddr,len,char);
-}
-
-/*
-=for apidoc savesharedsvpv
-
-A version of C<savesharedpv()> which allocates the duplicate string in
-memory which is shared between threads.
-
-=cut
-*/
-
-char *
-Perl_savesharedsvpv(pTHX_ SV *sv)
-{
- STRLEN len;
- const char * const pv = SvPV_const(sv, len);
-
- PERL_ARGS_ASSERT_SAVESHAREDSVPV;
-
- return savesharedpvn(pv, len);
-}
-
/* the SV for Perl_form() and mess() is not kept in an arena */
STATIC SV *