Stas Bekman wrote:
[EMAIL PROTECTED] wrote:

gozer 2004/09/09 15:16:38


+/* XXX: There is no XS accessible splice() */
+static void modperl_av_remove_entry(pTHX_ AV *av, I32 index)
+{
+ I32 i;
+ AV *tmpav = newAV();
+
+ /* stash the entries _before_ the item to delete */
+ for (i=0; i<=index; i++) {
+ av_store(tmpav, i, SvREFCNT_inc(av_shift(av)));
+ }
+ + /* make size at the beginning of the array */
+ av_unshift(av, index-1);
+ + /* add stashed entries back */
+ for (i=0; i<index; i++) {
+ av_store(av, i, *av_fetch(tmpav, i, 0));
+ }
+ + SvREFCNT_dec(tmpav);


shouldn't it just be sv_free'd? how do you know when the enclosing scope will force the free'ing when you can safely free it right here.

I was under the impression that SV *av = newAV(); [...] SvREFCNT_dec(av);

would achieve just that.

Are you saying you'd want to see:
SV *av = newAV();
[...]
av_undef(av);

?

--
--------------------------------------------------------------------------------
Philippe M. Chiasson m/gozer\@(apache|cpan|ectoplasm)\.org/ GPG KeyID : 88C3A5A5
http://gozer.ectoplasm.org/     F9BF E0C2 480E 7680 1AE5 3631 CB32 A107 88C3A5A5

Attachment: signature.asc
Description: OpenPGP digital signature



Reply via email to