3 ms·
If you're implementing C23 compatibility, you could do auto p = (thing_t *)malloc(sizeof(thing_t)); and you get both DRY and avoid (void *) casting.
by KerrAvon 2y ago
If you're implementing C23 compatibility, you could do
auto p = (thing_t *)malloc(sizeof(thing_t));
and you get both DRY and avoid (void *) casting.
- dcuthbertson 2y ago> and you get both DRY and avoid (void *) casting. While that line of code is DRY, it doesn't avoid casting "void *" to "thing_t *".