Skip to content

Commit ddecdf3

Browse files
committed
S_new_SV: args unused, static inline & defined, rename with Perl_ prefix
When sv_inline.h was created in 75acd14 and a number of things moved into it, the S_new_SV debugging function should have been made PERL_STATIC_INLINE and given the Perl_ prefix. This commit now does those things. It also marks the arguments to Perl_new_SV as PERL_UNUSED_ARG, reducing warnings on some builds. Additionally, now that we can use inline functions, the new_SV() macro is now just a call to this inline function, rather than being that only on DEBUG_LEAKING_SCALARS builds and a multi-line macro the rest of the time.
1 parent 8cacb84 commit ddecdf3

File tree

4 files changed

+19
-22
lines changed

4 files changed

+19
-22
lines changed

embed.fnc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5731,6 +5731,9 @@ S |void |glob_assign_glob \
57315731
|const int dtype
57325732
S |bool |glob_2number |NN GV * const gv
57335733
Cp |SV * |more_sv
5734+
Cp |SV * |new_sv |NN const char *file \
5735+
|int line \
5736+
|NN const char *func
57345737
S |void |not_a_number |NN SV * const sv
57355738
S |void |not_incrementable \
57365739
|NN SV * const sv

embed.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2063,6 +2063,7 @@
20632063
# endif /* defined(PERL_IN_REGEX_ENGINE) */
20642064
# if defined(PERL_IN_SV_C)
20652065
# define more_sv() Perl_more_sv(aTHX)
2066+
# define new_sv(a,b,c) Perl_new_sv(aTHX_ a,b,c)
20662067
# if defined(PERL_CORE)
20672068
# define F0convert S_F0convert
20682069
# define anonymise_cv_maybe(a,b) S_anonymise_cv_maybe(aTHX_ a,b)

proto.h

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sv_inline.h

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,15 @@
6868
SV* Perl_more_sv(pTHX);
6969

7070
/* new_SV(): return a new, empty SV head */
71-
72-
#ifdef DEBUG_LEAKING_SCALARS
73-
/* provide a real function for a debugger to play with */
74-
STATIC SV*
75-
S_new_SV(pTHX_ const char *file, int line, const char *func)
71+
PERL_STATIC_INLINE SV*
72+
Perl_new_SV(pTHX_ const char *file, int line, const char *func)
7673
{
7774
SV* sv;
75+
#ifndef DEBUG_LEAKING_SCALARS
76+
PERL_UNUSED_ARG(file);
77+
PERL_UNUSED_ARG(line);
78+
PERL_UNUSED_ARG(func);
79+
#endif
7880

7981
if (PL_sv_root)
8082
uproot_SV(sv);
@@ -83,6 +85,7 @@ S_new_SV(pTHX_ const char *file, int line, const char *func)
8385
SvANY(sv) = 0;
8486
SvREFCNT(sv) = 1;
8587
SvFLAGS(sv) = 0;
88+
#ifdef DEBUG_LEAKING_SCALARS
8689
sv->sv_debug_optype = PL_op ? PL_op->op_type : 0;
8790
sv->sv_debug_line = (U16) (PL_parser && PL_parser->copline != NOLINE
8891
? PL_parser->copline
@@ -99,25 +102,10 @@ S_new_SV(pTHX_ const char *file, int line, const char *func)
99102
MEM_LOG_NEW_SV(sv, file, line, func);
100103
DEBUG_m(PerlIO_printf(Perl_debug_log, "0x%" UVxf ": (%05ld) new_SV (from %s:%d [%s])\n",
101104
PTR2UV(sv), (long)sv->sv_debug_serial, file, line, func));
102-
105+
#endif
103106
return sv;
104107
}
105-
# define new_SV(p) (p)=S_new_SV(aTHX_ __FILE__, __LINE__, FUNCTION__)
106-
107-
#else
108-
# define new_SV(p) \
109-
STMT_START { \
110-
if (PL_sv_root) \
111-
uproot_SV(p); \
112-
else \
113-
(p) = Perl_more_sv(aTHX); \
114-
SvANY(p) = 0; \
115-
SvREFCNT(p) = 1; \
116-
SvFLAGS(p) = 0; \
117-
MEM_LOG_NEW_SV(p, __FILE__, __LINE__, FUNCTION__); \
118-
} STMT_END
119-
#endif
120-
108+
# define new_SV(p) (p)=Perl_new_SV(aTHX_ __FILE__, __LINE__, FUNCTION__)
121109

122110
typedef struct xpvhv_with_aux XPVHV_WITH_AUX;
123111

0 commit comments

Comments
 (0)