News for hackers. Stuff that matters.
Re:Beej’s Guide to C Programming [pdf] by unwind on Friday April 23, 2021 @06:16AM (#26913053)
That is of course fine, with the drawback that it requires a public definition of the foo type.

I would write the allocation as

    foo * const g = malloc(sizeof *g);
to avoid repeating the type name and "lock" the allocation to the variable. If the type on the left hand side ever would change, this still does the right thing.

There are no comments on this comment yet.