mirror of
https://github.com/TokTok/c-toxcore
synced 2026-05-26 09:44:41 +00:00
cleanup: Some random cleanups, mostly related to mem.
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
/* Tests that we can send messages to friends.
|
||||
*/
|
||||
|
||||
#include <pthread.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "auto_test_support.h"
|
||||
|
||||
|
||||
+1
-1
@@ -195,7 +195,7 @@ void ac_iterate(ACSession *ac)
|
||||
free(temp_audio_buffer);
|
||||
}
|
||||
|
||||
int ac_queue_message(Mono_Time *mono_time, void *cs, struct RTPMessage *msg)
|
||||
int ac_queue_message(const Mono_Time *mono_time, void *cs, struct RTPMessage *msg)
|
||||
{
|
||||
ACSession *ac = (ACSession *)cs;
|
||||
|
||||
|
||||
+1
-1
@@ -67,7 +67,7 @@ ACSession *ac_new(Mono_Time *mono_time, const Logger *log, ToxAV *av, uint32_t f
|
||||
toxav_audio_receive_frame_cb *cb, void *cb_data);
|
||||
void ac_kill(ACSession *ac);
|
||||
void ac_iterate(ACSession *ac);
|
||||
int ac_queue_message(Mono_Time *mono_time, void *cs, struct RTPMessage *msg);
|
||||
int ac_queue_message(const Mono_Time *mono_time, void *cs, struct RTPMessage *msg);
|
||||
int ac_reconfigure_encoder(ACSession *ac, uint32_t bit_rate, uint32_t sampling_rate, uint8_t channels);
|
||||
|
||||
#endif /* C_TOXCORE_TOXAV_AUDIO_H */
|
||||
|
||||
+1
-1
@@ -823,7 +823,7 @@ static struct RTPHeader rtp_default_header(const RTPSession *session, uint32_t l
|
||||
header.ma = 0;
|
||||
header.pt = session->payload_type % 128;
|
||||
header.sequnum = session->sequnum;
|
||||
Mono_Time *mt = toxav_get_av_mono_time(session->toxav);
|
||||
const Mono_Time *mt = toxav_get_av_mono_time(session->toxav);
|
||||
if (mt != nullptr) {
|
||||
header.timestamp = current_time_monotonic(mt);
|
||||
} else {
|
||||
|
||||
+1
-1
@@ -147,7 +147,7 @@ struct RTPWorkBufferList {
|
||||
|
||||
#define DISMISS_FIRST_LOST_VIDEO_PACKET_COUNT 10
|
||||
|
||||
typedef int rtp_m_cb(Mono_Time *mono_time, void *cs, struct RTPMessage *msg);
|
||||
typedef int rtp_m_cb(const Mono_Time *mono_time, void *cs, struct RTPMessage *msg);
|
||||
|
||||
/**
|
||||
* RTP control session.
|
||||
|
||||
+2
-3
@@ -5,7 +5,6 @@
|
||||
#include "toxav.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -21,7 +20,7 @@
|
||||
#include "../toxcore/network.h"
|
||||
#include "../toxcore/tox.h"
|
||||
#include "../toxcore/tox_private.h"
|
||||
#include "../toxcore/tox_struct.h"
|
||||
#include "../toxcore/tox_struct.h" // IWYU pragma: keep
|
||||
#include "../toxcore/util.h"
|
||||
|
||||
// TODO(zoff99): don't hardcode this, let the application choose it
|
||||
@@ -342,7 +341,7 @@ uint32_t toxav_iteration_interval(const ToxAV *av)
|
||||
* @param frame_time the duration of the current frame in ms
|
||||
* @param start_time the timestamp when decoding of this frame started
|
||||
*/
|
||||
static void calc_interval(ToxAV *av, DecodeTimeStats *stats, int32_t frame_time, uint64_t start_time)
|
||||
static void calc_interval(const ToxAV *av, DecodeTimeStats *stats, int32_t frame_time, uint64_t start_time)
|
||||
{
|
||||
stats->interval = frame_time < stats->average ? 0 : (frame_time - stats->average);
|
||||
stats->total += current_time_monotonic(av->toxav_mono_time) - start_time;
|
||||
|
||||
+2
-4
@@ -8,14 +8,12 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "msi.h"
|
||||
#include "ring_buffer.h"
|
||||
#include "rtp.h"
|
||||
|
||||
#include "../toxcore/ccompat.h"
|
||||
#include "../toxcore/logger.h"
|
||||
#include "../toxcore/mono_time.h"
|
||||
#include "../toxcore/network.h"
|
||||
|
||||
/**
|
||||
* Soft deadline the decoder should attempt to meet, in "us" (microseconds).
|
||||
@@ -143,7 +141,7 @@ static void vc_init_encoder_cfg(const Logger *log, vpx_codec_enc_cfg_t *cfg, int
|
||||
#endif /* 0 */
|
||||
}
|
||||
|
||||
VCSession *vc_new(const Logger *log, Mono_Time *mono_time, ToxAV *av, uint32_t friend_number,
|
||||
VCSession *vc_new(const Logger *log, const Mono_Time *mono_time, ToxAV *av, uint32_t friend_number,
|
||||
toxav_video_receive_frame_cb *cb, void *cb_data)
|
||||
{
|
||||
VCSession *vc = (VCSession *)calloc(1, sizeof(VCSession));
|
||||
@@ -346,7 +344,7 @@ void vc_iterate(VCSession *vc)
|
||||
}
|
||||
}
|
||||
|
||||
int vc_queue_message(Mono_Time *mono_time, void *cs, struct RTPMessage *msg)
|
||||
int vc_queue_message(const Mono_Time *mono_time, void *cs, struct RTPMessage *msg)
|
||||
{
|
||||
VCSession *vc = (VCSession *)cs;
|
||||
|
||||
|
||||
+2
-2
@@ -44,11 +44,11 @@ typedef struct VCSession {
|
||||
const Logger *log;
|
||||
} VCSession;
|
||||
|
||||
VCSession *vc_new(const Logger *log, Mono_Time *mono_time, ToxAV *av, uint32_t friend_number,
|
||||
VCSession *vc_new(const Logger *log, const Mono_Time *mono_time, ToxAV *av, uint32_t friend_number,
|
||||
toxav_video_receive_frame_cb *cb, void *cb_data);
|
||||
void vc_kill(VCSession *vc);
|
||||
void vc_iterate(VCSession *vc);
|
||||
int vc_queue_message(Mono_Time *mono_time, void *cs, struct RTPMessage *msg);
|
||||
int vc_queue_message(const Mono_Time *mono_time, void *cs, struct RTPMessage *msg);
|
||||
int vc_reconfigure_encoder(VCSession *vc, uint32_t bit_rate, uint16_t width, uint16_t height, int16_t kf_max_dist);
|
||||
|
||||
#endif /* C_TOXCORE_TOXAV_VIDEO_H */
|
||||
|
||||
+2
-2
@@ -137,7 +137,7 @@ void getaddress(const Messenger *m, uint8_t *address)
|
||||
}
|
||||
|
||||
non_null()
|
||||
static bool send_online_packet(Messenger *m, int friendcon_id)
|
||||
static bool send_online_packet(const Messenger *m, int friendcon_id)
|
||||
{
|
||||
const uint8_t packet[1] = {PACKET_ID_ONLINE};
|
||||
return write_cryptpacket(m->net_crypto, friend_connection_crypt_connection_id(m->fr_c, friendcon_id), packet,
|
||||
@@ -145,7 +145,7 @@ static bool send_online_packet(Messenger *m, int friendcon_id)
|
||||
}
|
||||
|
||||
non_null()
|
||||
static bool send_offline_packet(Messenger *m, int friendcon_id)
|
||||
static bool send_offline_packet(const Messenger *m, int friendcon_id)
|
||||
{
|
||||
const uint8_t packet[1] = {PACKET_ID_OFFLINE};
|
||||
return write_cryptpacket(m->net_crypto, friend_connection_crypt_connection_id(m->fr_c, friendcon_id), packet,
|
||||
|
||||
+7
-7
@@ -248,7 +248,7 @@ static bool is_groupnumber_valid(const Group_Chats *g_c, uint32_t groupnumber)
|
||||
|
||||
/** @brief Set the size of the groupchat list to num.
|
||||
*
|
||||
* @retval false if realloc fails.
|
||||
* @retval false if mem_vrealloc fails.
|
||||
* @retval true if it succeeds.
|
||||
*/
|
||||
non_null()
|
||||
@@ -1067,7 +1067,7 @@ static bool freeze_peer(Group_Chats *g_c, uint32_t groupnumber, int peer_index,
|
||||
return false;
|
||||
}
|
||||
|
||||
Group_Peer *temp = (Group_Peer *)mem_vrealloc(g_c->m->mem, g->frozen, g->numfrozen + 1, sizeof(Group_Peer));
|
||||
Group_Peer *temp = (Group_Peer *)mem_vrealloc(g_c->mem, g->frozen, g->numfrozen + 1, sizeof(Group_Peer));
|
||||
|
||||
if (temp == nullptr) {
|
||||
return false;
|
||||
@@ -1085,7 +1085,7 @@ static bool freeze_peer(Group_Chats *g_c, uint32_t groupnumber, int peer_index,
|
||||
|
||||
++g->numfrozen;
|
||||
|
||||
delete_old_frozen(g, g_c->m->mem);
|
||||
delete_old_frozen(g, g_c->mem);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1572,7 +1572,7 @@ int group_set_max_frozen(const Group_Chats *g_c, uint32_t groupnumber, uint32_t
|
||||
}
|
||||
|
||||
g->maxfrozen = maxfrozen;
|
||||
delete_old_frozen(g, g_c->m->mem);
|
||||
delete_old_frozen(g, g_c->mem);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -3805,19 +3805,19 @@ bool conferences_load_state_section(Group_Chats *g_c, const uint8_t *data, uint3
|
||||
}
|
||||
|
||||
/** Create new groupchat instance. */
|
||||
Group_Chats *new_groupchats(const Mono_Time *mono_time, Messenger *m)
|
||||
Group_Chats *new_groupchats(const Mono_Time *mono_time, const Memory *mem, Messenger *m)
|
||||
{
|
||||
if (m == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Group_Chats *temp = (Group_Chats *)mem_alloc(m->mem, sizeof(Group_Chats));
|
||||
Group_Chats *temp = (Group_Chats *)mem_alloc(mem, sizeof(Group_Chats));
|
||||
|
||||
if (temp == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
temp->mem = m->mem;
|
||||
temp->mem = mem;
|
||||
temp->mono_time = mono_time;
|
||||
temp->m = m;
|
||||
temp->fr_c = m->fr_c;
|
||||
|
||||
+2
-1
@@ -15,6 +15,7 @@
|
||||
#include "Messenger.h"
|
||||
#include "attributes.h"
|
||||
#include "crypto_core.h"
|
||||
#include "mem.h"
|
||||
#include "mono_time.h"
|
||||
#include "state.h"
|
||||
|
||||
@@ -390,7 +391,7 @@ bool conferences_load_state_section(
|
||||
|
||||
/** Create new groupchat instance. */
|
||||
non_null()
|
||||
Group_Chats *new_groupchats(const Mono_Time *mono_time, Messenger *m);
|
||||
Group_Chats *new_groupchats(const Mono_Time *mono_time, const Memory *mem, Messenger *m);
|
||||
|
||||
/** main groupchats loop. */
|
||||
non_null(1) nullable(2)
|
||||
|
||||
@@ -2736,7 +2736,7 @@ static bool send_gc_peer_exchange(const GC_Chat *chat, GC_Connection *gconn)
|
||||
* Return -5 if supplied group password is invalid.
|
||||
* Return -6 if we fail to add the peer to the peer list.
|
||||
* Return -7 if peer's role cannot be validated.
|
||||
* Return -8 if malloc fails.
|
||||
* Return -8 if memory allocation fails.
|
||||
*/
|
||||
non_null(1, 2, 4) nullable(6)
|
||||
static int handle_gc_peer_info_response(const GC_Session *c, GC_Chat *chat, uint32_t peer_number,
|
||||
@@ -5534,7 +5534,7 @@ static int unwrap_group_handshake_packet(const Logger *log, const Memory *mem, c
|
||||
*
|
||||
* Return length of encrypted packet on success.
|
||||
* Return -1 if packet size is invalid.
|
||||
* Return -2 on malloc failure.
|
||||
* Return -2 on memory allocation failure.
|
||||
* Return -3 if encryption fails.
|
||||
*/
|
||||
non_null()
|
||||
@@ -6825,7 +6825,7 @@ int peer_add(GC_Chat *chat, const IP_Port *ipp, const uint8_t *public_key)
|
||||
GC_Peer *tmp_group = (GC_Peer *)mem_vrealloc(chat->mem, chat->group, chat->numpeers + 1, sizeof(GC_Peer));
|
||||
|
||||
if (tmp_group == nullptr) {
|
||||
LOGGER_ERROR(chat->log, "Failed to allocate memory for group realloc");
|
||||
LOGGER_ERROR(chat->log, "Failed to allocate memory for group mem_vrealloc");
|
||||
|
||||
if (tcp_connection_num != -1) {
|
||||
kill_tcp_connection_to(chat->tcp_conn, tcp_connection_num);
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
|
||||
@@ -17,9 +17,9 @@ void gca_onion_init(GC_Announces_List *group_announce, Onion_Announce *onion_a);
|
||||
|
||||
non_null()
|
||||
int create_gca_announce_request(
|
||||
const Memory *mem, const Random *rng, uint8_t *packet, uint16_t max_packet_length, const uint8_t *dest_client_id,
|
||||
const uint8_t *public_key, const uint8_t *secret_key, const uint8_t *ping_id,
|
||||
const uint8_t *client_id, const uint8_t *data_public_key, uint64_t sendback_data,
|
||||
const uint8_t *gc_data, uint16_t gc_data_length);
|
||||
const Memory *mem, const Random *rng, uint8_t *packet, uint16_t max_packet_length,
|
||||
const uint8_t *dest_client_id, const uint8_t *public_key, const uint8_t *secret_key,
|
||||
const uint8_t *ping_id, const uint8_t *client_id, const uint8_t *data_public_key,
|
||||
uint64_t sendback_data, const uint8_t *gc_data, uint16_t gc_data_length);
|
||||
|
||||
#endif /* C_TOXCORE_TOXCORE_GROUP_ONION_ANNOUNCE_H */
|
||||
|
||||
+1
-1
@@ -115,7 +115,7 @@ static bool resize(BS_List *list, uint32_t new_size)
|
||||
return true;
|
||||
}
|
||||
|
||||
uint8_t *data = (uint8_t *)mem_vrealloc(list->mem, list->data, list->element_size, new_size);
|
||||
uint8_t *data = (uint8_t *)mem_brealloc(list->mem, list->data, new_size * list->element_size);
|
||||
|
||||
if (data == nullptr) {
|
||||
return false;
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
#include "logger.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -52,6 +53,7 @@ void logger_kill(Logger *log)
|
||||
|
||||
void logger_callback_log(Logger *log, logger_cb *function, void *context, void *userdata)
|
||||
{
|
||||
assert(log != nullptr);
|
||||
log->callback = function;
|
||||
log->context = context;
|
||||
log->userdata = userdata;
|
||||
|
||||
@@ -53,6 +53,12 @@ void *mem_balloc(const Memory *mem, uint32_t size)
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void *mem_brealloc(const Memory *mem, void *ptr, uint32_t size)
|
||||
{
|
||||
void *const new_ptr = mem->funcs->realloc(mem->obj, ptr, size);
|
||||
return new_ptr;
|
||||
}
|
||||
|
||||
void *mem_alloc(const Memory *mem, uint32_t size)
|
||||
{
|
||||
void *const ptr = mem->funcs->calloc(mem->obj, 1, size);
|
||||
|
||||
@@ -45,6 +45,14 @@ const Memory *os_memory(void);
|
||||
*/
|
||||
non_null() void *mem_balloc(const Memory *mem, uint32_t size);
|
||||
|
||||
/**
|
||||
* @brief Resize an array of a given size for built-in types.
|
||||
*
|
||||
* If used for a type other than byte-sized types, `size` needs to be manually
|
||||
* multiplied by the element size.
|
||||
*/
|
||||
non_null(1) nullable(2) void *mem_brealloc(const Memory *mem, void *ptr, uint32_t size);
|
||||
|
||||
/**
|
||||
* @brief Allocate a single object.
|
||||
*
|
||||
|
||||
+1
-1
@@ -218,7 +218,7 @@ void mono_time_set_current_time_callback(Mono_Time *mono_time,
|
||||
* The starting point is unspecified and in particular is likely not comparable
|
||||
* to the return value of `mono_time_get_ms()`.
|
||||
*/
|
||||
uint64_t current_time_monotonic(Mono_Time *mono_time)
|
||||
uint64_t current_time_monotonic(const Mono_Time *mono_time)
|
||||
{
|
||||
return mono_time->current_time_callback(mono_time->user_data);
|
||||
}
|
||||
|
||||
+1
-1
@@ -87,7 +87,7 @@ bool mono_time_is_timeout(const Mono_Time *mono_time, uint64_t timestamp, uint64
|
||||
* to the return value of `mono_time_get_ms()`.
|
||||
*/
|
||||
non_null()
|
||||
uint64_t current_time_monotonic(Mono_Time *mono_time);
|
||||
uint64_t current_time_monotonic(const Mono_Time *mono_time);
|
||||
|
||||
/**
|
||||
* Override implementation of `current_time_monotonic()` (for tests).
|
||||
|
||||
+17
-16
@@ -10,6 +10,7 @@
|
||||
*/
|
||||
#include "net_crypto.h"
|
||||
|
||||
#include <pthread.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "DHT.h"
|
||||
@@ -673,7 +674,7 @@ static IP_Port return_ip_port_connection(const Net_Crypto *c, int crypt_connecti
|
||||
* @retval 0 on success.
|
||||
*/
|
||||
non_null()
|
||||
static int send_packet_to(Net_Crypto *c, int crypt_connection_id, const uint8_t *data, uint16_t length)
|
||||
static int send_packet_to(const Net_Crypto *c, int crypt_connection_id, const uint8_t *data, uint16_t length)
|
||||
{
|
||||
// TODO(irungentoo): TCP, etc...
|
||||
Crypto_Connection *conn = get_crypto_connection(c, crypt_connection_id);
|
||||
@@ -981,7 +982,7 @@ static int generate_request_packet(uint8_t *data, uint16_t length, const Packets
|
||||
* @return number of requested packets on success.
|
||||
*/
|
||||
non_null()
|
||||
static int handle_request_packet(const Memory *mem, Mono_Time *mono_time, Packets_Array *send_array,
|
||||
static int handle_request_packet(const Memory *mem, const Mono_Time *mono_time, Packets_Array *send_array,
|
||||
const uint8_t *data, uint16_t length,
|
||||
uint64_t *latest_send_time, uint64_t rtt_time)
|
||||
{
|
||||
@@ -1064,7 +1065,7 @@ static int handle_request_packet(const Memory *mem, Mono_Time *mono_time, Packet
|
||||
* @retval 0 on success.
|
||||
*/
|
||||
non_null()
|
||||
static int send_data_packet(Net_Crypto *c, int crypt_connection_id, const uint8_t *data, uint16_t length)
|
||||
static int send_data_packet(const Net_Crypto *c, int crypt_connection_id, const uint8_t *data, uint16_t length)
|
||||
{
|
||||
const uint16_t max_length = MAX_CRYPTO_PACKET_SIZE - (1 + sizeof(uint16_t) + CRYPTO_MAC_SIZE);
|
||||
|
||||
@@ -1102,7 +1103,7 @@ static int send_data_packet(Net_Crypto *c, int crypt_connection_id, const uint8_
|
||||
* @retval 0 on success.
|
||||
*/
|
||||
non_null()
|
||||
static int send_data_packet_helper(Net_Crypto *c, int crypt_connection_id, uint32_t buffer_start, uint32_t num,
|
||||
static int send_data_packet_helper(const Net_Crypto *c, int crypt_connection_id, uint32_t buffer_start, uint32_t num,
|
||||
const uint8_t *data, uint16_t length)
|
||||
{
|
||||
if (length == 0 || length > MAX_CRYPTO_DATA_SIZE) {
|
||||
@@ -1124,7 +1125,7 @@ static int send_data_packet_helper(Net_Crypto *c, int crypt_connection_id, uint3
|
||||
}
|
||||
|
||||
non_null()
|
||||
static int reset_max_speed_reached(Net_Crypto *c, int crypt_connection_id)
|
||||
static int reset_max_speed_reached(const Net_Crypto *c, int crypt_connection_id)
|
||||
{
|
||||
Crypto_Connection *conn = get_crypto_connection(c, crypt_connection_id);
|
||||
|
||||
@@ -1159,7 +1160,7 @@ static int reset_max_speed_reached(Net_Crypto *c, int crypt_connection_id)
|
||||
* @return positive packet number if data was put into the queue.
|
||||
*/
|
||||
non_null()
|
||||
static int64_t send_lossless_packet(Net_Crypto *c, int crypt_connection_id, const uint8_t *data, uint16_t length,
|
||||
static int64_t send_lossless_packet(const Net_Crypto *c, int crypt_connection_id, const uint8_t *data, uint16_t length,
|
||||
bool congestion_control)
|
||||
{
|
||||
if (length == 0 || length > MAX_CRYPTO_DATA_SIZE) {
|
||||
@@ -1275,7 +1276,7 @@ static int handle_data_packet(const Net_Crypto *c, int crypt_connection_id, uint
|
||||
* @retval 0 on success.
|
||||
*/
|
||||
non_null()
|
||||
static int send_request_packet(Net_Crypto *c, int crypt_connection_id)
|
||||
static int send_request_packet(const Net_Crypto *c, int crypt_connection_id)
|
||||
{
|
||||
const Crypto_Connection *conn = get_crypto_connection(c, crypt_connection_id);
|
||||
|
||||
@@ -1300,7 +1301,7 @@ static int send_request_packet(Net_Crypto *c, int crypt_connection_id)
|
||||
* @return number of packets sent on success.
|
||||
*/
|
||||
non_null()
|
||||
static int send_requested_packets(Net_Crypto *c, int crypt_connection_id, uint32_t max_num)
|
||||
static int send_requested_packets(const Net_Crypto *c, int crypt_connection_id, uint32_t max_num)
|
||||
{
|
||||
if (max_num == 0) {
|
||||
return -1;
|
||||
@@ -1414,7 +1415,7 @@ static int clear_temp_packet(const Net_Crypto *c, int crypt_connection_id)
|
||||
* @retval 0 on success.
|
||||
*/
|
||||
non_null()
|
||||
static int send_temp_packet(Net_Crypto *c, int crypt_connection_id)
|
||||
static int send_temp_packet(const Net_Crypto *c, int crypt_connection_id)
|
||||
{
|
||||
Crypto_Connection *conn = get_crypto_connection(c, crypt_connection_id);
|
||||
|
||||
@@ -1442,7 +1443,7 @@ static int send_temp_packet(Net_Crypto *c, int crypt_connection_id)
|
||||
* @retval 0 on success.
|
||||
*/
|
||||
non_null()
|
||||
static int create_send_handshake(Net_Crypto *c, int crypt_connection_id, const uint8_t *cookie,
|
||||
static int create_send_handshake(const Net_Crypto *c, int crypt_connection_id, const uint8_t *cookie,
|
||||
const uint8_t *dht_public_key)
|
||||
{
|
||||
const Crypto_Connection *conn = get_crypto_connection(c, crypt_connection_id);
|
||||
@@ -1472,7 +1473,7 @@ static int create_send_handshake(Net_Crypto *c, int crypt_connection_id, const u
|
||||
* @retval 0 on success.
|
||||
*/
|
||||
non_null()
|
||||
static int send_kill_packet(Net_Crypto *c, int crypt_connection_id)
|
||||
static int send_kill_packet(const Net_Crypto *c, int crypt_connection_id)
|
||||
{
|
||||
const Crypto_Connection *conn = get_crypto_connection(c, crypt_connection_id);
|
||||
|
||||
@@ -1647,7 +1648,7 @@ static int handle_data_packet_core(Net_Crypto *c, int crypt_connection_id, const
|
||||
}
|
||||
|
||||
non_null()
|
||||
static int handle_packet_cookie_response(Net_Crypto *c, int crypt_connection_id, const uint8_t *packet, uint16_t length)
|
||||
static int handle_packet_cookie_response(const Net_Crypto *c, int crypt_connection_id, const uint8_t *packet, uint16_t length)
|
||||
{
|
||||
Crypto_Connection *conn = get_crypto_connection(c, crypt_connection_id);
|
||||
|
||||
@@ -1679,7 +1680,7 @@ static int handle_packet_cookie_response(Net_Crypto *c, int crypt_connection_id,
|
||||
}
|
||||
|
||||
non_null(1, 3) nullable(5)
|
||||
static int handle_packet_crypto_hs(Net_Crypto *c, int crypt_connection_id, const uint8_t *packet, uint16_t length,
|
||||
static int handle_packet_crypto_hs(const Net_Crypto *c, int crypt_connection_id, const uint8_t *packet, uint16_t length,
|
||||
void *userdata)
|
||||
{
|
||||
Crypto_Connection *conn = get_crypto_connection(c, crypt_connection_id);
|
||||
@@ -2757,7 +2758,7 @@ static void send_crypto_packets(Net_Crypto *c)
|
||||
* @retval 1 if max speed was reached for this connection (no more data can be physically through the pipe).
|
||||
* @retval 0 if it wasn't reached.
|
||||
*/
|
||||
bool max_speed_reached(Net_Crypto *c, int crypt_connection_id)
|
||||
bool max_speed_reached(const Net_Crypto *c, int crypt_connection_id)
|
||||
{
|
||||
return reset_max_speed_reached(c, crypt_connection_id) != 0;
|
||||
}
|
||||
@@ -2792,7 +2793,7 @@ uint32_t crypto_num_free_sendqueue_slots(const Net_Crypto *c, int crypt_connecti
|
||||
*
|
||||
* congestion_control: should congestion control apply to this packet?
|
||||
*/
|
||||
int64_t write_cryptpacket(Net_Crypto *c, int crypt_connection_id, const uint8_t *data, uint16_t length,
|
||||
int64_t write_cryptpacket(const Net_Crypto *c, int crypt_connection_id, const uint8_t *data, uint16_t length,
|
||||
bool congestion_control)
|
||||
{
|
||||
if (length == 0) {
|
||||
@@ -2878,7 +2879,7 @@ int cryptpacket_received(const Net_Crypto *c, int crypt_connection_id, uint32_t
|
||||
*
|
||||
* The first byte of data must be in the PACKET_ID_RANGE_LOSSY.
|
||||
*/
|
||||
int send_lossy_cryptpacket(Net_Crypto *c, int crypt_connection_id, const uint8_t *data, uint16_t length)
|
||||
int send_lossy_cryptpacket(const Net_Crypto *c, int crypt_connection_id, const uint8_t *data, uint16_t length)
|
||||
{
|
||||
if (length == 0 || length > MAX_CRYPTO_DATA_SIZE) {
|
||||
return -1;
|
||||
|
||||
@@ -9,10 +9,7 @@
|
||||
#ifndef C_TOXCORE_TOXCORE_NET_CRYPTO_H
|
||||
#define C_TOXCORE_TOXCORE_NET_CRYPTO_H
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
#include "DHT.h"
|
||||
#include "LAN_discovery.h"
|
||||
#include "TCP_client.h"
|
||||
#include "TCP_connection.h"
|
||||
#include "attributes.h"
|
||||
@@ -242,7 +239,7 @@ uint32_t crypto_num_free_sendqueue_slots(const Net_Crypto *c, int crypt_connecti
|
||||
* @retval 0 if it wasn't reached.
|
||||
*/
|
||||
non_null()
|
||||
bool max_speed_reached(Net_Crypto *c, int crypt_connection_id);
|
||||
bool max_speed_reached(const Net_Crypto *c, int crypt_connection_id);
|
||||
|
||||
/** @brief Sends a lossless cryptopacket.
|
||||
*
|
||||
@@ -254,7 +251,7 @@ bool max_speed_reached(Net_Crypto *c, int crypt_connection_id);
|
||||
* congestion_control: should congestion control apply to this packet?
|
||||
*/
|
||||
non_null()
|
||||
int64_t write_cryptpacket(Net_Crypto *c, int crypt_connection_id,
|
||||
int64_t write_cryptpacket(const Net_Crypto *c, int crypt_connection_id,
|
||||
const uint8_t *data, uint16_t length, bool congestion_control);
|
||||
|
||||
/** @brief Check if packet_number was received by the other side.
|
||||
@@ -282,7 +279,7 @@ int cryptpacket_received(const Net_Crypto *c, int crypt_connection_id, uint32_t
|
||||
* The first byte of data must be in the PACKET_ID_RANGE_LOSSY.
|
||||
*/
|
||||
non_null()
|
||||
int send_lossy_cryptpacket(Net_Crypto *c, int crypt_connection_id, const uint8_t *data, uint16_t length);
|
||||
int send_lossy_cryptpacket(const Net_Crypto *c, int crypt_connection_id, const uint8_t *data, uint16_t length);
|
||||
|
||||
/** @brief Add a tcp relay, associating it to a crypt_connection_id.
|
||||
*
|
||||
|
||||
+1
-1
@@ -929,7 +929,7 @@ static Tox *tox_new_system(const struct Tox_Options *options, Tox_Err_New *error
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
tox->m->conferences_object = new_groupchats(tox->mono_time, tox->m);
|
||||
tox->m->conferences_object = new_groupchats(tox->mono_time, sys->mem, tox->m);
|
||||
|
||||
if (tox->m->conferences_object == nullptr) {
|
||||
kill_messenger(tox->m);
|
||||
|
||||
Reference in New Issue
Block a user