What's the problem with what I provided? You've introduced so many bugs!
Your function now accepts any scalar as an argument.
create_bar(123); is accepted.
create_bar('abc'); is accepted.
create_bar(['a', 'b']); is accepted.
create_bar({key => 'val'}); is accepted.
If the argument is a reference, it will unconditionally be treated as an object of type type_foo, even if it isn't even an object.
warn gets executed when you pass undef.
Do you even know what XSRETURN_UNDEF does? I don't, but I'm pretty sure it's not used properly.
You should be using type T_PTROBJ if you didn't accept undef, so you should base your code on T_PTROBJ.
Updated
In reply to Re^3: Passing NULL pointer through XS without "Use of uninitialized value in subroutine entry"
by ikegami
in thread Passing NULL pointer through XS without "Use of uninitialized value in subroutine entry"
by kscaldef
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |