|
|
|
|
|
by kazinator
1086 days ago
|
|
But if you change the type name, you are probably also doing a search and replace. In the end, the only justification for the latter rather than the former is that the pointer name is often a short name like vec, and so sizeof *vec is shorter than the alternative. That has advantages. If there is a typo in a short name, you're more likely to see it. I can easily miss the typo: struct Vector3D *vec = malloc(sizeof(struct Vector2D));
The sizeof <object-expr> also doesn't require parentheses, so it's shorter by two characters right off the bat. |
|
You also can't search-replace a type name as easily, because other variables will have the same original type but not need to be updated.