assert(newmax >= AvMAX(av));
Newx(ary, newmax+1, SV*);
Copy(AvALLOC(av), ary, AvMAX(av)+1, SV*);
- if (AvMAX(av) > 64)
- offer_nice_chunk(AvALLOC(av),
- (AvMAX(av)+1) * sizeof(const SV *));
- else
- Safefree(AvALLOC(av));
+ Safefree(AvALLOC(av));
AvALLOC(av) = ary;
#endif
#ifdef Perl_safesysmalloc_size
}
if (SvREADONLY(av) && key >= AvFILL(av))
- Perl_croak(aTHX_ "%s", PL_no_modify);
+ Perl_croak_no_modify(aTHX);
if (!AvREAL(av) && AvREIFY(av))
av_reify(av);
sv_magic(val, MUTABLE_SV(av), toLOWER(mg->mg_type), 0, key);
}
if (PL_delaymagic && mg->mg_type == PERL_MAGIC_isa)
- PL_delaymagic |= DM_ARRAY;
+ PL_delaymagic |= DM_ARRAY_ISA;
else
mg_set(MUTABLE_SV(av));
}
into the array, so they may be freed after the call to av_make. The new AV
will have a reference count of 1.
+Perl equivalent: C<my @new_array = ($scalar1, $scalar2, $scalar3...);>
+
=cut
*/
#endif
if (SvREADONLY(av))
- Perl_croak(aTHX_ "%s", PL_no_modify);
+ Perl_croak_no_modify(aTHX);
/* Give any tie a chance to cleanup first */
if (SvRMAGICAL(av)) {
const MAGIC* const mg = SvMAGIC(av);
if (PL_delaymagic && mg && mg->mg_type == PERL_MAGIC_isa)
- PL_delaymagic |= DM_ARRAY;
+ PL_delaymagic |= DM_ARRAY_ISA;
else
mg_clear(MUTABLE_SV(av));
}
assert(SvTYPE(av) == SVt_PVAV);
if (SvREADONLY(av))
- Perl_croak(aTHX_ "%s", PL_no_modify);
+ Perl_croak_no_modify(aTHX);
if ((mg = SvTIED_mg((const SV *)av, PERL_MAGIC_tied))) {
Perl_magic_methcall(aTHX_ MUTABLE_SV(av), mg, "PUSH", G_DISCARD, 1,
assert(SvTYPE(av) == SVt_PVAV);
if (SvREADONLY(av))
- Perl_croak(aTHX_ "%s", PL_no_modify);
+ Perl_croak_no_modify(aTHX);
if ((mg = SvTIED_mg((const SV *)av, PERL_MAGIC_tied))) {
retval = Perl_magic_methcall(aTHX_ MUTABLE_SV(av), mg, "POP", 0, 0);
if (retval)
assert(SvTYPE(av) == SVt_PVAV);
if (SvREADONLY(av))
- Perl_croak(aTHX_ "%s", PL_no_modify);
+ Perl_croak_no_modify(aTHX);
if ((mg = SvTIED_mg((const SV *)av, PERL_MAGIC_tied))) {
Perl_magic_methcall(aTHX_ MUTABLE_SV(av), mg, "UNSHIFT",
assert(SvTYPE(av) == SVt_PVAV);
if (SvREADONLY(av))
- Perl_croak(aTHX_ "%s", PL_no_modify);
+ Perl_croak_no_modify(aTHX);
if ((mg = SvTIED_mg((const SV *)av, PERL_MAGIC_tied))) {
retval = Perl_magic_methcall(aTHX_ MUTABLE_SV(av), mg, "SHIFT", 0, 0);
if (retval)
Returns the highest index in the array. The number of elements in the
array is C<av_len(av) + 1>. Returns -1 if the array is empty.
+The Perl equivalent for this is C<$#myarray>.
+
=cut
*/
Perl's C<$#array = $fill;>.
The number of elements in the an array will be C<fill + 1> after
-av_fill() returns. If the array was previously shorter then the
+av_fill() returns. If the array was previously shorter, then the
additional elements appended are set to C<PL_sv_undef>. If the array
was longer, then the excess elements are freed. C<av_fill(av, -1)> is
the same as C<av_clear(av)>.
/*
=for apidoc av_delete
-Deletes the element indexed by C<key> from the array. Returns the
-deleted element. If C<flags> equals C<G_DISCARD>, the element is freed
-and null is returned. Perl equivalent: C<my $elem = delete($myarray[$idx]);>
-for the non-C<G_DISCARD> version and a void-context C<delete($myarray[$idx]);>
-for the C<G_DISCARD> version.
+Deletes the element indexed by C<key> from the array, makes the element mortal,
+and returns it. If C<flags> equals C<G_DISCARD>, the element is freed and null
+is returned. Perl equivalent: C<my $elem = delete($myarray[$idx]);> for the
+non-C<G_DISCARD> version and a void-context C<delete($myarray[$idx]);> for the
+C<G_DISCARD> version.
=cut
*/
assert(SvTYPE(av) == SVt_PVAV);
if (SvREADONLY(av))
- Perl_croak(aTHX_ "%s", PL_no_modify);
+ Perl_croak_no_modify(aTHX);
if (SvRMAGICAL(av)) {
const MAGIC * const tied_magic
if (SvRMAGICAL(av)) {
const MAGIC * const tied_magic
= mg_find((const SV *)av, PERL_MAGIC_tied);
- if (tied_magic || mg_find((const SV *)av, PERL_MAGIC_regdata)) {
+ const MAGIC * const regdata_magic
+ = mg_find((const SV *)av, PERL_MAGIC_regdata);
+ if (tied_magic || regdata_magic) {
SV * const sv = sv_newmortal();
MAGIC *mg;
/* Handle negative array indices 20020222 MJD */
key += AvFILL(av) + 1;
if (key < 0)
return FALSE;
+ else
+ return TRUE;
}
}
+ if(key >= 0 && regdata_magic) {
+ if (key <= AvFILL(av))
+ return TRUE;
+ else
+ return FALSE;
+ }
+
mg_copy(MUTABLE_SV(av), sv, 0, key);
mg = mg_find(sv, PERL_MAGIC_tiedelem);
if (mg) {