From 92ffad1a72bc8c422426d52ac408bd71242dd047 Mon Sep 17 00:00:00 2001 From: iphydf Date: Sun, 28 Jan 2018 21:30:39 +0000 Subject: Use nullptr as NULL pointer constant instead of NULL or 0. This changes only code, no string literals or comments. --- toxcore/TCP_connection.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'toxcore/TCP_connection.c') diff --git a/toxcore/TCP_connection.c b/toxcore/TCP_connection.c index a43069da..3ce75948 100644 --- a/toxcore/TCP_connection.c +++ b/toxcore/TCP_connection.c @@ -78,7 +78,7 @@ const uint8_t *tcp_connections_public_key(const TCP_Connections *tcp_c) array, \ (num) * sizeof(element_type)), \ temp_pointer ? (array = temp_pointer, 0) : -1) \ - : (free(array), array = NULL, 0)) + : (free(array), array = nullptr, 0)) /* return 1 if the connections_number is not valid. @@ -90,7 +90,7 @@ static bool connections_number_not_valid(const TCP_Connections *tcp_c, int conne return 1; } - if (tcp_c->connections == NULL) { + if (tcp_c->connections == nullptr) { return 1; } @@ -110,7 +110,7 @@ static bool tcp_connections_number_not_valid(const TCP_Connections *tcp_c, int t return 1; } - if (tcp_c->tcp_connections == NULL) { + if (tcp_c->tcp_connections == nullptr) { return 1; } @@ -239,7 +239,7 @@ static int wipe_tcp_connection(TCP_Connections *tcp_c, int tcp_connections_numbe static TCP_Connection_to *get_connection(const TCP_Connections *tcp_c, int connections_number) { if (connections_number_not_valid(tcp_c, connections_number)) { - return 0; + return nullptr; } return &tcp_c->connections[connections_number]; @@ -248,7 +248,7 @@ static TCP_Connection_to *get_connection(const TCP_Connections *tcp_c, int conne static TCP_con *get_tcp_connection(const TCP_Connections *tcp_c, int tcp_connections_number) { if (tcp_connections_number_not_valid(tcp_c, tcp_connections_number)) { - return 0; + return nullptr; } return &tcp_c->tcp_connections[tcp_connections_number]; @@ -824,7 +824,7 @@ static int sleep_tcp_relay_connection(TCP_Connections *tcp_c, int tcp_connection memcpy(tcp_con->relay_pk, tcp_con_public_key(tcp_con->connection), CRYPTO_PUBLIC_KEY_SIZE); kill_TCP_connection(tcp_con->connection); - tcp_con->connection = NULL; + tcp_con->connection = nullptr; unsigned int i; @@ -922,7 +922,7 @@ static int tcp_response_callback(void *object, uint8_t connection_id, const uint TCP_Connection_to *con_to = get_connection(tcp_c, connections_number); - if (con_to == NULL) { + if (con_to == nullptr) { return -1; } @@ -1368,14 +1368,14 @@ int set_tcp_onion_status(TCP_Connections *tcp_c, bool status) */ TCP_Connections *new_tcp_connections(const uint8_t *secret_key, TCP_Proxy_Info *proxy_info) { - if (secret_key == NULL) { - return NULL; + if (secret_key == nullptr) { + return nullptr; } TCP_Connections *temp = (TCP_Connections *)calloc(1, sizeof(TCP_Connections)); - if (temp == NULL) { - return NULL; + if (temp == nullptr) { + return nullptr; } memcpy(temp->self_secret_key, secret_key, CRYPTO_SECRET_KEY_SIZE); @@ -1400,7 +1400,7 @@ static void do_tcp_conns(TCP_Connections *tcp_c, void *userdata) tcp_con = get_tcp_connection(tcp_c, i); // Make sure the TCP connection wasn't dropped in any of the callbacks. - assert(tcp_con != NULL); + assert(tcp_con != nullptr); if (tcp_con_status(tcp_con->connection) == TCP_CLIENT_DISCONNECTED) { if (tcp_con->status == TCP_CONN_CONNECTED) { -- cgit v1.2.3