Skip to content

Commit 9ab77e0

Browse files
committed
cleanup: Fix calloc argument order.
See TokTok/hs-tokstyle#102
1 parent 83d5d0d commit 9ab77e0

File tree

8 files changed

+15
-15
lines changed

8 files changed

+15
-15
lines changed

toxav/audio.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ static bool reconfigure_audio_decoder(ACSession *ac, int32_t sampling_rate, int8
2828
ACSession *ac_new(Mono_Time *mono_time, const Logger *log, ToxAV *av, uint32_t friend_number,
2929
toxav_audio_receive_frame_cb *cb, void *cb_data)
3030
{
31-
ACSession *ac = (ACSession *)calloc(sizeof(ACSession), 1);
31+
ACSession *ac = (ACSession *)calloc(1, sizeof(ACSession));
3232

3333
if (!ac) {
3434
LOGGER_WARNING(log, "Allocation failed! Application might misbehave!");
@@ -273,13 +273,13 @@ static struct JitterBuffer *jbuf_new(uint32_t capacity)
273273
size *= 2;
274274
}
275275

276-
struct JitterBuffer *q = (struct JitterBuffer *)calloc(sizeof(struct JitterBuffer), 1);
276+
struct JitterBuffer *q = (struct JitterBuffer *)calloc(1, sizeof(struct JitterBuffer));
277277

278278
if (!q) {
279279
return nullptr;
280280
}
281281

282-
q->queue = (struct RTPMessage **)calloc(sizeof(struct RTPMessage *), size);
282+
q->queue = (struct RTPMessage **)calloc(size, sizeof(struct RTPMessage *));
283283

284284
if (!q->queue) {
285285
free(q);

toxav/bwcontroller.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ static void send_update(BWController *bwc);
6262
BWController *bwc_new(Messenger *m, Tox *tox, uint32_t friendnumber, m_cb *mcb, void *mcb_user_data,
6363
Mono_Time *bwc_mono_time)
6464
{
65-
BWController *retu = (BWController *)calloc(sizeof(BWController), 1);
65+
BWController *retu = (BWController *)calloc(1, sizeof(BWController));
6666

6767
if (retu == nullptr) {
6868
return nullptr;

toxav/groupav.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ static Group_JitterBuffer *create_queue(unsigned int capacity)
3737
size *= 2;
3838
}
3939

40-
Group_JitterBuffer *q = (Group_JitterBuffer *)calloc(sizeof(Group_JitterBuffer), 1);
40+
Group_JitterBuffer *q = (Group_JitterBuffer *)calloc(1, sizeof(Group_JitterBuffer));
4141

4242
if (!q) {
4343
return nullptr;
4444
}
4545

46-
q->queue = (Group_Audio_Packet **)calloc(sizeof(Group_Audio_Packet *), size);
46+
q->queue = (Group_Audio_Packet **)calloc(size, sizeof(Group_Audio_Packet *));
4747

4848
if (!q->queue) {
4949
free(q);

toxav/msi.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ MSISession *msi_new(Messenger *m)
9494
return nullptr;
9595
}
9696

97-
MSISession *retu = (MSISession *)calloc(sizeof(MSISession), 1);
97+
MSISession *retu = (MSISession *)calloc(1, sizeof(MSISession));
9898

9999
if (retu == nullptr) {
100100
LOGGER_ERROR(m->log, "Allocation failed! Program might misbehave!");
@@ -530,7 +530,7 @@ static MSICall *new_call(MSISession *session, uint32_t friend_number)
530530
{
531531
assert(session);
532532

533-
MSICall *rc = (MSICall *)calloc(sizeof(MSICall), 1);
533+
MSICall *rc = (MSICall *)calloc(1, sizeof(MSICall));
534534

535535
if (rc == nullptr) {
536536
return nullptr;
@@ -540,7 +540,7 @@ static MSICall *new_call(MSISession *session, uint32_t friend_number)
540540
rc->friend_number = friend_number;
541541

542542
if (session->calls == nullptr) { /* Creating */
543-
session->calls = (MSICall **)calloc(sizeof(MSICall *), friend_number + 1);
543+
session->calls = (MSICall **)calloc(friend_number + 1, sizeof(MSICall *));
544544

545545
if (session->calls == nullptr) {
546546
free(rc);

toxav/ring_buffer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ bool rb_read(RingBuffer *b, void **p)
6666

6767
RingBuffer *rb_new(int size)
6868
{
69-
RingBuffer *buf = (RingBuffer *)calloc(sizeof(RingBuffer), 1);
69+
RingBuffer *buf = (RingBuffer *)calloc(1, sizeof(RingBuffer));
7070

7171
if (!buf) {
7272
return nullptr;

toxav/toxav.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ ToxAV *toxav_new(Tox *tox, Toxav_Err_New *error)
165165
goto RETURN;
166166
}
167167

168-
av = (ToxAV *)calloc(sizeof(ToxAV), 1);
168+
av = (ToxAV *)calloc(1, sizeof(ToxAV));
169169

170170
if (av == nullptr) {
171171
LOGGER_WARNING(m->log, "Allocation failed!");
@@ -1244,7 +1244,7 @@ static ToxAVCall *call_new(ToxAV *av, uint32_t friend_number, Toxav_Err_Call *er
12441244
goto RETURN;
12451245
}
12461246

1247-
call = (ToxAVCall *)calloc(sizeof(ToxAVCall), 1);
1247+
call = (ToxAVCall *)calloc(1, sizeof(ToxAVCall));
12481248

12491249
if (call == nullptr) {
12501250
rc = TOXAV_ERR_CALL_MALLOC;
@@ -1262,7 +1262,7 @@ static ToxAVCall *call_new(ToxAV *av, uint32_t friend_number, Toxav_Err_Call *er
12621262
}
12631263

12641264
if (av->calls == nullptr) { /* Creating */
1265-
av->calls = (ToxAVCall **)calloc(sizeof(ToxAVCall *), friend_number + 1);
1265+
av->calls = (ToxAVCall **)calloc(friend_number + 1, sizeof(ToxAVCall *));
12661266

12671267
if (av->calls == nullptr) {
12681268
pthread_mutex_destroy(call->toxav_call_mutex);

toxav/video.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ static void vc_init_encoder_cfg(const Logger *log, vpx_codec_enc_cfg_t *cfg, int
143143
VCSession *vc_new(Mono_Time *mono_time, const Logger *log, ToxAV *av, uint32_t friend_number,
144144
toxav_video_receive_frame_cb *cb, void *cb_data)
145145
{
146-
VCSession *vc = (VCSession *)calloc(sizeof(VCSession), 1);
146+
VCSession *vc = (VCSession *)calloc(1, sizeof(VCSession));
147147
vpx_codec_err_t rc;
148148

149149
if (!vc) {

toxcore/TCP_client.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ TCP_Client_Connection *new_TCP_connection(const Mono_Time *mono_time, IP_Port ip
698698
return nullptr;
699699
}
700700

701-
TCP_Client_Connection *temp = (TCP_Client_Connection *)calloc(sizeof(TCP_Client_Connection), 1);
701+
TCP_Client_Connection *temp = (TCP_Client_Connection *)calloc(1, sizeof(TCP_Client_Connection));
702702

703703
if (temp == nullptr) {
704704
kill_sock(sock);

0 commit comments

Comments
 (0)