5 ms·
I don't think OP meant that as an optional parameter, but more like: // Definition foo * bar(foo * useme); And then use as // Allocate foo for me pls.
by wereHamster 7y ago
I don't think OP meant that as an optional parameter, but more like:
// Definition
foo * bar(foo * useme);
And then use as
// Allocate foo for me pls.
foo * result = bar(NULL)
or
// I'll allocate the buffer myself ktkxbye.
foo * result = bar(malloc(…))
- kazinator 7y agoThat's what you'd do in C. Since the malloc return has to be checked, and the object may have to be initialized, the API could provide enough convenience to justify it.