19 ms·
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(siz
by unwind 6y ago
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.