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:
Xavier Del Campo Romero 2022-06-26 19:50:32 +02:00
parent eee1205446
commit f938bb790e
3 changed files with 3 additions and 3 deletions

View File

@ -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)

View File

@ -87,5 +87,5 @@ end:
void mouse_init(struct mouse *const m)
{
memset(m, 0, sizeof *m);
*m = (const struct mouse){0};
}

View File

@ -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;