Deprecate memset(3) over C99 compound literals for zero-init
Using memset(3) does not ensure pointers are assigned to NULL for all platforms.
This commit is contained in:
parent
eee1205446
commit
f938bb790e
|
@ -53,7 +53,7 @@ bool keyboard_justpressed(const struct keyboard *const k,
|
|||
|
||||
void keyboard_init(struct keyboard *const k)
|
||||
{
|
||||
memset(k, 0, sizeof *k);
|
||||
*k = (const struct keyboard){0};
|
||||
}
|
||||
|
||||
const char *keyboard_key_str(const enum keyboard_key k)
|
||||
|
|
|
@ -87,5 +87,5 @@ end:
|
|||
|
||||
void mouse_init(struct mouse *const m)
|
||||
{
|
||||
memset(m, 0, sizeof *m);
|
||||
*m = (const struct mouse){0};
|
||||
}
|
||||
|
|
|
@ -711,7 +711,7 @@ int human_player_render(const struct human_player *const h,
|
|||
int human_player_init(const struct human_player_cfg *const cfg,
|
||||
struct human_player *const h)
|
||||
{
|
||||
memset(h, 0, sizeof *h);
|
||||
*h = (const struct human_player){0};
|
||||
|
||||
if (player_init(&cfg->pl, &h->pl))
|
||||
return -1;
|
||||
|
|
Loading…
Reference in New Issue