Skip to content

Commit 2664aa6

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 751a423 commit 2664aa6

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

embed.fnc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,8 @@ ARdp |SSize_t|av_len |NN AV *av
747747
ARdp |AV * |av_make |SSize_t size \
748748
|NN SV **strp
749749
CRdip |AV * |av_new_alloc |SSize_t size \
750-
|bool zeroflag
750+
|bool zeroflag \
751+
assert(size > 0)
751752
p |SV * |av_nonelem |NN AV *av \
752753
|SSize_t ix
753754
Adp |SV * |av_pop |NN AV *av

inline.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,10 @@ initialized.
195195
PERL_STATIC_INLINE AV *
196196
Perl_av_new_alloc(pTHX_ SSize_t size, bool zeroflag)
197197
{
198+
PERL_ARGS_ASSERT_AV_NEW_ALLOC;
199+
198200
AV * const av = newAV();
199201
SV** ary;
200-
PERL_ARGS_ASSERT_AV_NEW_ALLOC;
201-
assert(size > 0);
202202

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

proto.h

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

0 commit comments

Comments
 (0)