From my point of view, there is a lot of missing macro and/or typedef and C subroutine code. In particular, without seeing the typedef/macro code behind the LHS AV *arr and the code for the subroutine newAV, I find it impossible to construct reliably what is being handed down to Perl.