mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Keep the code consistent.
This commit is contained in:
parent
8b5d9dc13e
commit
ba169b7c21
|
@ -1648,44 +1648,48 @@ int Messenger_load(Messenger *m, uint8_t *data, uint32_t length)
|
||||||
/* Return the number of friends in the instance m.
|
/* Return the number of friends in the instance m.
|
||||||
* You should use this to determine how much memory to allocate
|
* You should use this to determine how much memory to allocate
|
||||||
* for copy_friendlist. */
|
* for copy_friendlist. */
|
||||||
size_t count_friendlist(Messenger *m)
|
uint32_t count_friendlist(Messenger *m)
|
||||||
{
|
{
|
||||||
size_t ret = 0;
|
uint32_t ret = 0;
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
|
|
||||||
for (i = 0; i < m->numfriends; i++) {
|
for (i = 0; i < m->numfriends; i++) {
|
||||||
if (m->friendlist[i].status > 0) {
|
if (m->friendlist[i].status > 0) {
|
||||||
ret++;
|
ret++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Copy a list of valid friend IDs into the array out_list.
|
/* Copy a list of valid friend IDs into the array out_list.
|
||||||
* If out_list is NULL, returns -1.
|
* If out_list is NULL, returns 0.
|
||||||
* Otherwise, returns the number of elements copied.
|
* Otherwise, returns the number of elements copied.
|
||||||
* If the array was too small, the contents
|
* If the array was too small, the contents
|
||||||
* of out_list will be truncated to list_size. */
|
* of out_list will be truncated to list_size. */
|
||||||
size_t copy_friendlist(Messenger *m, int *out_list, size_t list_size)
|
uint32_t copy_friendlist(Messenger *m, int *out_list, uint32_t list_size)
|
||||||
{
|
{
|
||||||
if (!out_list)
|
if (!out_list)
|
||||||
return -1;
|
return 0;
|
||||||
|
|
||||||
if (m->numfriends == 0) {
|
if (m->numfriends == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
size_t ret = 0;
|
uint32_t ret = 0;
|
||||||
|
|
||||||
for (i = 0; i < m->numfriends; i++) {
|
for (i = 0; i < m->numfriends; i++) {
|
||||||
if (i >= list_size) {
|
if (i >= list_size) {
|
||||||
break; /* Abandon ship */
|
break; /* Abandon ship */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m->friendlist[i].status > 0) {
|
if (m->friendlist[i].status > 0) {
|
||||||
out_list[i] = i;
|
out_list[i] = i;
|
||||||
ret++;
|
ret++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -459,14 +459,14 @@ int Messenger_load(Messenger *m, uint8_t *data, uint32_t length);
|
||||||
/* Return the number of friends in the instance m.
|
/* Return the number of friends in the instance m.
|
||||||
* You should use this to determine how much memory to allocate
|
* You should use this to determine how much memory to allocate
|
||||||
* for copy_friendlist. */
|
* for copy_friendlist. */
|
||||||
size_t count_friendlist(Messenger *m);
|
uint32_t count_friendlist(Messenger *m);
|
||||||
|
|
||||||
/* Copy a list of valid friend IDs into the array out_list.
|
/* Copy a list of valid friend IDs into the array out_list.
|
||||||
* If out_list is NULL, returns -1.
|
* If out_list is NULL, returns 0.
|
||||||
* Otherwise, returns the number of elements copied.
|
* Otherwise, returns the number of elements copied.
|
||||||
* If the array was too small, the contents
|
* If the array was too small, the contents
|
||||||
* of out_list will be truncated to list_size. */
|
* of out_list will be truncated to list_size. */
|
||||||
size_t copy_friendlist(Messenger *m, int *out_list, size_t list_size);
|
uint32_t copy_friendlist(Messenger *m, int *out_list, uint32_t list_size);
|
||||||
|
|
||||||
/* Allocate and return a list of valid friend id's. List must be freed by the
|
/* Allocate and return a list of valid friend id's. List must be freed by the
|
||||||
* caller.
|
* caller.
|
||||||
|
|
|
@ -265,18 +265,18 @@ void tox_set_sends_receipts(void *tox, int friendnumber, int yesno)
|
||||||
/* Return the number of friends in the instance m.
|
/* Return the number of friends in the instance m.
|
||||||
* You should use this to determine how much memory to allocate
|
* You should use this to determine how much memory to allocate
|
||||||
* for copy_friendlist. */
|
* for copy_friendlist. */
|
||||||
size_t tox_count_friendlist(void *tox)
|
uint32_t tox_count_friendlist(void *tox)
|
||||||
{
|
{
|
||||||
Messenger *m = tox;
|
Messenger *m = tox;
|
||||||
return count_friendlist(m);
|
return count_friendlist(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Copy a list of valid friend IDs into the array out_list.
|
/* Copy a list of valid friend IDs into the array out_list.
|
||||||
* If out_list is NULL, returns -1.
|
* If out_list is NULL, returns 0.
|
||||||
* Otherwise, returns the number of elements copied.
|
* Otherwise, returns the number of elements copied.
|
||||||
* If the array was too small, the contents
|
* If the array was too small, the contents
|
||||||
* of out_list will be truncated to list_size. */
|
* of out_list will be truncated to list_size. */
|
||||||
size_t tox_copy_friendlist(void *tox, int *out_list, size_t list_size)
|
uint32_t tox_copy_friendlist(void *tox, int *out_list, uint32_t list_size)
|
||||||
{
|
{
|
||||||
Messenger *m = tox;
|
Messenger *m = tox;
|
||||||
return copy_friendlist(m, out_list, list_size);
|
return copy_friendlist(m, out_list, list_size);
|
||||||
|
|
|
@ -283,14 +283,14 @@ void tox_set_sends_receipts(Tox *tox, int friendnumber, int yesno);
|
||||||
/* Return the number of friends in the instance m.
|
/* Return the number of friends in the instance m.
|
||||||
* You should use this to determine how much memory to allocate
|
* You should use this to determine how much memory to allocate
|
||||||
* for copy_friendlist. */
|
* for copy_friendlist. */
|
||||||
size_t tox_count_friendlist(void *tox);
|
uint32_t tox_count_friendlist(void *tox);
|
||||||
|
|
||||||
/* Copy a list of valid friend IDs into the array out_list.
|
/* Copy a list of valid friend IDs into the array out_list.
|
||||||
* If out_list is NULL, returns -1.
|
* If out_list is NULL, returns 0.
|
||||||
* Otherwise, returns the number of elements copied.
|
* Otherwise, returns the number of elements copied.
|
||||||
* If the array was too small, the contents
|
* If the array was too small, the contents
|
||||||
* of out_list will be truncated to list_size. */
|
* of out_list will be truncated to list_size. */
|
||||||
size_t tox_copy_friendlist(void *tox, int *out_list, size_t list_size);
|
uint32_t tox_copy_friendlist(void *tox, int *out_list, uint32_t list_size);
|
||||||
|
|
||||||
/* Set the function that will be executed when a friend request is received.
|
/* Set the function that will be executed when a friend request is received.
|
||||||
* Function format is function(uint8_t * public_key, uint8_t * data, uint16_t length)
|
* Function format is function(uint8_t * public_key, uint8_t * data, uint16_t length)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user