Commits

Anonymous committed d9b430c

Added sv_2mortal to make the test of the "array-from-scratch" pass.

  • Participants
  • Parent commits 3853cd1

Comments (0)

Files changed (2)

File perl5/ext-embed-internals/docbook/examples/incremental-examples-1/XSTest/lib/XSTest.xs

                 }
             }
 
+            /* We need to mortalize the AV because it is returned by
+             * the function (on the stack), and so will not be garbage
+             * collected. According to:
+             *
+             * http://www.nntp.perl.org/group/perl.xs/2008/12/msg2521.html
+             *
+             * AV *'s and HV *'s are not mortalized by default as is the case
+             * for SV *'s, so they need to be mortalized explicitly.
+             * */
+
+            sv_2mortal((SV *)ret);
+
             myerror:
             RETVAL = ret;
         }

File perl5/ext-embed-internals/docbook/examples/incremental-examples-1/XSTest/t/10-array-from-scratch.t

             my @array1 = ("One", MyTestDestroyed->new("CamelCase"));
             my @array2 = (20,30,40);
 
-            # $combined = XSTest::concat_two_array_refs(\@array1, \@array2);
-            $combined = [@array1, @array2];
+            $combined = XSTest::concat_two_array_refs(\@array1, \@array2);
+            # $combined = [@array1, @array2];
         }
 
         # TEST
         is ($combined->[1]->{'id'}, "CamelCase", 
             "concat_two_arrays - Garbage Collection - elem 1/id"
         );
+
     }
 
     # TEST