Skip to content

Commit ae7ce87

Browse files
committed
Replace malloc(); memset() with calloc()
Less error prone and more consistent with rest of the code. Signed-off-by: Nir Soffer <[email protected]>
1 parent 273726b commit ae7ce87

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

main.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,7 @@ struct state {
9595

9696
static void state_add_socket_fd(struct state *state, int socket_fd) {
9797
dispatch_semaphore_wait(state->sem, DISPATCH_TIME_FOREVER);
98-
struct conn *conn = malloc(sizeof(struct conn));
99-
memset(conn, 0, sizeof(*conn));
98+
struct conn *conn = calloc(1, sizeof(*conn));
10099
conn->socket_fd = socket_fd;
101100
if (state->conns == NULL) {
102101
state->conns = conn;

0 commit comments

Comments
 (0)