SV *make_aoa_c( int n_rows, int n_cols ) {
int i, j;
char *foo = "foo";
AV *table = newAV();
AV *row;
for ( i = 0; i < n_rows; ++i ) {
row = ( AV * ) sv_2mortal( ( SV * ) newAV() );
for ( j = 0; j < n_cols; ++j ) {
av_push( row, newSVpv( foo, 0 ) );
}
av_push( table, sv_2mortal( newRV( ( SV * ) row ) ) );
}
return newRV( ( SV * ) table );
}
####
% perl test_aoa.pl 1
1: 78844 (280041 us)
2: 78884 (247865 us)
3: 78892 (237725 us)
4: 78900 (245755 us)
5: 78908 (235251 us)
6: 78916 (235712 us)
7: 78924 (246926 us)
8: 78932 (237128 us)
9: 78940 (237369 us)
10: 78948 (238528 us)
##
##
Attempt to free unreferenced scalar: SV 0x5b2c620, Perl interpreter: 0x603010 at test_aoa.pl line 22.