laziness, impatience, and hubris | |
PerlMonks |
Re^9: Inline::C and NULL pointersby Marshall (Canon) |
on Dec 21, 2021 at 06:18 UTC ( [id://11139789]=note: print w/replies, xml ) | Need Help?? |
Rob, I am glad that other Monks jumped in on this. I agree with this: I'm not convinced that the need to pass NULL pointers from perl to C functions is all that common. As I mentioned in previous posts, the OP is confronted with some poorly written C code that he can't change. This NULL pointer idea arises from an I/F that says: "if you give a pointer to memory, I will use that memory for output, assuming without question that you have given me enough memory for my yet to be generated output. If you don't give me such a pointer, I will give you a pointer to my non-thread-safe non-recursion-safe static memory." This is a bullshit I/F. But the OP can't change that. NULL as the 2nd param is a weird situation. If there could be one arg and an optional second arg, then normally this would be implemented with a variable number of args - you don't put NULL, for that second arg - it is simply not there at all for the caller. This of course requires different C code than what the OP is dealing with. printf() for example uses a variable number of arguments. I did have fun with Inline::C and found it to be "easy to use" for all the "heavy lifting" that is does.
In Section
Seekers of Perl Wisdom
|
|