Skip to content

Commit

Permalink
Use compound literals to zero out structs instead of memset
Browse files Browse the repository at this point in the history
  • Loading branch information
zugz committed Nov 14, 2020
1 parent 4581dee commit ba5ded9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/audio_call.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ bool init_call(Call *call)
return false;
}

memset(call, 0, sizeof(Call));
*call = (struct Call) {
0
};

call->status = cs_Pending;

Expand Down
5 changes: 4 additions & 1 deletion src/conference.c
Original file line number Diff line number Diff line change
Expand Up @@ -560,11 +560,14 @@ static void update_peer_list(Tox *m, uint32_t conferencenum, uint32_t num_peers,
}

realloc_peer_list(chat, num_peers);
memset(chat->peer_list, 0, num_peers * sizeof(ConferencePeer));

for (uint32_t i = 0; i < num_peers; ++i) {
ConferencePeer *peer = &chat->peer_list[i];

*peer = (struct ConferencePeer) {
0
};

Tox_Err_Conference_Peer_Query err;
tox_conference_peer_get_public_key(m, conferencenum, i, peer->pubkey, &err);

Expand Down

0 comments on commit ba5ded9

Please sign in to comment.