add #undef malloc just prior to your use of malloc
Ooow .... I like *that* idea :-) I've actually placed the '#undef malloc' at the very start of the C code in that script, and the script now runs fine.
Beyond that, nothing has yet been established. Now it's just a matter of seeing whether the same approach can help with PDL (which is where the actual problem that prompted this thread lies.)