4 ms·
This: struct Vec3* v = malloc(sizeof(struct Vec3)); is better written as: struct Vec3 * const v = malloc(sizeof *v); I don't love this. Other p
by jandrese 10mo ago
This:
struct Vec3* v = malloc(sizeof(struct Vec3));
is better written as:
struct Vec3 * const v = malloc(sizeof *v);
I don't love this. Other people are going to think you're only allocating a pointer. It's potentially confusing.
- f1shy 10mo agoI also personally find totally confusing leaving the * in the middle of nowhere, like flapping in the breeze.
- unwind 10mo agoUh, okay, but if you need to constantly write code as if people reading it don't understand the language, then ... I don't know how to do that. :) It's not possible to know C code and think that sizeof *v and sizeof v somehow mean the same thing, at least not to me.
- ux266478 10mo agono, but you can misread the two interchangeably no matter how familiar you are with the language.