use Perl memory alloc functions instead of malloc