mirror of
https://github.com/TokTok/c-toxcore
synced 2026-10-23 10:52:21 +00:00
cleanup: Fix calloc argument order.
See https://github.com/TokTok/hs-tokstyle/pull/102
This commit is contained in:
8 files changed
+15
-15
No files matched your search
+3
-3
@@ -28,7 +28,7 @@ static bool reconfigure_audio_decoder(ACSession *ac, int32_t sampling_rate, int8
|
||||
ACSession *ac_new(Mono_Time *mono_time, const Logger *log, ToxAV *av, uint32_t friend_number,
|
||||
toxav_audio_receive_frame_cb *cb, void *cb_data)
|
||||
{
|
||||
ACSession *ac = (ACSession *)calloc(sizeof(ACSession), 1);
|
||||
ACSession *ac = (ACSession *)calloc(1, sizeof(ACSession));
|
||||
|
||||
if (!ac) {
|
||||
LOGGER_WARNING(log, "Allocation failed! Application might misbehave!");
|
||||
@@ -273,13 +273,13 @@ static struct JitterBuffer *jbuf_new(uint32_t capacity)
|
||||
size *= 2;
|
||||
}
|
||||
|
||||
struct JitterBuffer *q = (struct JitterBuffer *)calloc(sizeof(struct JitterBuffer), 1);
|
||||
struct JitterBuffer *q = (struct JitterBuffer *)calloc(1, sizeof(struct JitterBuffer));
|
||||
|
||||
if (!q) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
q->queue = (struct RTPMessage **)calloc(sizeof(struct RTPMessage *), size);
|
||||
q->queue = (struct RTPMessage **)calloc(size, sizeof(struct RTPMessage *));
|
||||
|
||||
if (!q->queue) {
|
||||
free(q);
|
||||
|
||||
@@ -62,7 +62,7 @@ static void send_update(BWController *bwc);
|
||||
BWController *bwc_new(Messenger *m, Tox *tox, uint32_t friendnumber, m_cb *mcb, void *mcb_user_data,
|
||||
Mono_Time *bwc_mono_time)
|
||||
{
|
||||
BWController *retu = (BWController *)calloc(sizeof(BWController), 1);
|
||||
BWController *retu = (BWController *)calloc(1, sizeof(BWController));
|
||||
|
||||
if (retu == nullptr) {
|
||||
return nullptr;
|
||||
|
||||
+2
-2
@@ -37,13 +37,13 @@ static Group_JitterBuffer *create_queue(unsigned int capacity)
|
||||
size *= 2;
|
||||
}
|
||||
|
||||
Group_JitterBuffer *q = (Group_JitterBuffer *)calloc(sizeof(Group_JitterBuffer), 1);
|
||||
Group_JitterBuffer *q = (Group_JitterBuffer *)calloc(1, sizeof(Group_JitterBuffer));
|
||||
|
||||
if (!q) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
q->queue = (Group_Audio_Packet **)calloc(sizeof(Group_Audio_Packet *), size);
|
||||
q->queue = (Group_Audio_Packet **)calloc(size, sizeof(Group_Audio_Packet *));
|
||||
|
||||
if (!q->queue) {
|
||||
free(q);
|
||||
|
||||
+3
-3
@@ -94,7 +94,7 @@ MSISession *msi_new(Messenger *m)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MSISession *retu = (MSISession *)calloc(sizeof(MSISession), 1);
|
||||
MSISession *retu = (MSISession *)calloc(1, sizeof(MSISession));
|
||||
|
||||
if (retu == nullptr) {
|
||||
LOGGER_ERROR(m->log, "Allocation failed! Program might misbehave!");
|
||||
@@ -530,7 +530,7 @@ static MSICall *new_call(MSISession *session, uint32_t friend_number)
|
||||
{
|
||||
assert(session);
|
||||
|
||||
MSICall *rc = (MSICall *)calloc(sizeof(MSICall), 1);
|
||||
MSICall *rc = (MSICall *)calloc(1, sizeof(MSICall));
|
||||
|
||||
if (rc == nullptr) {
|
||||
return nullptr;
|
||||
@@ -540,7 +540,7 @@ static MSICall *new_call(MSISession *session, uint32_t friend_number)
|
||||
rc->friend_number = friend_number;
|
||||
|
||||
if (session->calls == nullptr) { /* Creating */
|
||||
session->calls = (MSICall **)calloc(sizeof(MSICall *), friend_number + 1);
|
||||
session->calls = (MSICall **)calloc(friend_number + 1, sizeof(MSICall *));
|
||||
|
||||
if (session->calls == nullptr) {
|
||||
free(rc);
|
||||
|
||||
+1
-1
@@ -66,7 +66,7 @@ bool rb_read(RingBuffer *b, void **p)
|
||||
|
||||
RingBuffer *rb_new(int size)
|
||||
{
|
||||
RingBuffer *buf = (RingBuffer *)calloc(sizeof(RingBuffer), 1);
|
||||
RingBuffer *buf = (RingBuffer *)calloc(1, sizeof(RingBuffer));
|
||||
|
||||
if (!buf) {
|
||||
return nullptr;
|
||||
|
||||
+3
-3
@@ -165,7 +165,7 @@ ToxAV *toxav_new(Tox *tox, Toxav_Err_New *error)
|
||||
goto RETURN;
|
||||
}
|
||||
|
||||
av = (ToxAV *)calloc(sizeof(ToxAV), 1);
|
||||
av = (ToxAV *)calloc(1, sizeof(ToxAV));
|
||||
|
||||
if (av == nullptr) {
|
||||
LOGGER_WARNING(m->log, "Allocation failed!");
|
||||
@@ -1244,7 +1244,7 @@ static ToxAVCall *call_new(ToxAV *av, uint32_t friend_number, Toxav_Err_Call *er
|
||||
goto RETURN;
|
||||
}
|
||||
|
||||
call = (ToxAVCall *)calloc(sizeof(ToxAVCall), 1);
|
||||
call = (ToxAVCall *)calloc(1, sizeof(ToxAVCall));
|
||||
|
||||
if (call == nullptr) {
|
||||
rc = TOXAV_ERR_CALL_MALLOC;
|
||||
@@ -1262,7 +1262,7 @@ static ToxAVCall *call_new(ToxAV *av, uint32_t friend_number, Toxav_Err_Call *er
|
||||
}
|
||||
|
||||
if (av->calls == nullptr) { /* Creating */
|
||||
av->calls = (ToxAVCall **)calloc(sizeof(ToxAVCall *), friend_number + 1);
|
||||
av->calls = (ToxAVCall **)calloc(friend_number + 1, sizeof(ToxAVCall *));
|
||||
|
||||
if (av->calls == nullptr) {
|
||||
pthread_mutex_destroy(call->toxav_call_mutex);
|
||||
|
||||
+1
-1
@@ -143,7 +143,7 @@ static void vc_init_encoder_cfg(const Logger *log, vpx_codec_enc_cfg_t *cfg, int
|
||||
VCSession *vc_new(Mono_Time *mono_time, const Logger *log, ToxAV *av, uint32_t friend_number,
|
||||
toxav_video_receive_frame_cb *cb, void *cb_data)
|
||||
{
|
||||
VCSession *vc = (VCSession *)calloc(sizeof(VCSession), 1);
|
||||
VCSession *vc = (VCSession *)calloc(1, sizeof(VCSession));
|
||||
vpx_codec_err_t rc;
|
||||
|
||||
if (!vc) {
|
||||
|
||||
@@ -698,7 +698,7 @@ TCP_Client_Connection *new_TCP_connection(const Mono_Time *mono_time, IP_Port ip
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
TCP_Client_Connection *temp = (TCP_Client_Connection *)calloc(sizeof(TCP_Client_Connection), 1);
|
||||
TCP_Client_Connection *temp = (TCP_Client_Connection *)calloc(1, sizeof(TCP_Client_Connection));
|
||||
|
||||
if (temp == nullptr) {
|
||||
kill_sock(sock);
|
||||
|
||||
Reference in new issue
Block a user