Skip to content

Commit

Permalink
A couple small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
JFreegman committed May 20, 2020
1 parent dcf3baf commit f012007
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
4 changes: 3 additions & 1 deletion src/friendlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,9 @@ void sort_friendlist_index(void)
}
}

qsort(Friends.index, Friends.num_friends, sizeof(uint32_t), index_name_cmp);
if (Friends.num_friends > 0) {
qsort(Friends.index, Friends.num_friends, sizeof(uint32_t), index_name_cmp);
}
}

static int index_name_cmp_block(const void *n1, const void *n2)
Expand Down
16 changes: 9 additions & 7 deletions src/toxic.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ void cb_toxcore_logger(Tox *m, TOX_LOG_LEVEL level, const char *file, uint32_t l
if (user_data) {
FILE *fp = (FILE *)user_data;
fprintf(fp, "[%d] %u:%s() - %s\n", level, line, func, message);
fflush(fp);
} else {
fprintf(stderr, "[%d] %u:%s() - %s\n", level, line, func, message);
}
Expand Down Expand Up @@ -354,17 +355,18 @@ static void load_friendlist(Tox *m)
sort_friendlist_index();
}

static void load_groups(Tox *m)
static void load_conferences(Tox *m)
{
size_t i;
size_t num_chats = tox_conference_get_chatlist_size(m);
uint32_t chatlist[num_chats];

if (num_chats) {
tox_conference_get_chatlist(m, chatlist);
if (num_chats == 0) {
return;
}

for (i = 0; i < num_chats; ++i) {
uint32_t chatlist[num_chats];
tox_conference_get_chatlist(m, chatlist);

for (size_t i = 0; i < num_chats; ++i) {
uint32_t groupnum = chatlist[i];

if (get_num_active_windows() >= MAX_WINDOWS_NUM) {
Expand Down Expand Up @@ -1371,7 +1373,7 @@ int main(int argc, char **argv)

prompt = init_windows(m);
prompt_init_statusbar(prompt, m, !datafile_exists);
load_groups(m);
load_conferences(m);

/* thread for ncurses stuff */
if (pthread_mutex_init(&Winthread.lock, NULL) != 0) {
Expand Down

0 comments on commit f012007

Please sign in to comment.