Skip to content

Commit 2a6c846

Browse files
committed
Move assert for av_new_alloc() to embed.fnc
You can't allocate a zero length array using this function; this uses the new assert() functionality in embed.fnc introduced in the previous few commits to cause the assertion to be placed in PERL_ARGS_ASSERT_AV_NEW_ALLOC rather than be in the function. There is no particular need to do this; this is mostly a demonstration of how it can be done.
1 parent 04ddac5 commit 2a6c846

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

embed.fnc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,8 @@ ARdp |SSize_t|av_len |NN AV *av
754754
ARdp |AV * |av_make |SSize_t size \
755755
|NN SV **strp
756756
CRdip |AV * |av_new_alloc |SSize_t size \
757-
|bool zeroflag
757+
|bool zeroflag \
758+
assert(size > 0)
758759
p |SV * |av_nonelem |NN AV *av \
759760
|SSize_t ix
760761
Adp |SV * |av_pop |NN AV *av

inline.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,10 @@ initialized.
191191
PERL_STATIC_INLINE AV *
192192
Perl_av_new_alloc(pTHX_ SSize_t size, bool zeroflag)
193193
{
194+
PERL_ARGS_ASSERT_AV_NEW_ALLOC;
195+
194196
AV * const av = newAV();
195197
SV** ary;
196-
PERL_ARGS_ASSERT_AV_NEW_ALLOC;
197-
assert(size > 0);
198198

199199
Newx(ary, size, SV*); /* Newx performs the memwrap check */
200200
AvALLOC(av) = ary;

proto.h

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)