Little conveniences
Greg Hudson
ghudson at MIT.EDU
Sun Oct 4 20:25:24 EDT 2009
On Sat, 2009-10-03 at 18:59 -0400, Danilo Almeida wrote:
> Wrt the out pointer argument casting issues, you can do something like this:
>
> #define k5alloc(Size, PointerToPointer) \
> ( !((*(PointerToPointer)) = calloc(Size, 1)) ? ENOMEM : 0 )
[...]
> ret = k5alloc(sizeof(foo), &foo);
Yeah, I was careful to say that it's not possible to write as a C
function; it would be possible as a macro. (Even, as you illustrate, a
macro using each of the arguments only once.) I'm a little reluctant to
introduce a construction which can only be defined as a macro, but if
people think it's worth that price to keep the order consistent, I'll
switch it around.
More information about the krbdev
mailing list