summaryrefslogtreecommitdiff
path: root/toxcore/tox.c
diff options
context:
space:
mode:
authorSebastian Stal <stal@kirara.ca>2013-09-21 14:47:30 -0700
committerSebastian Stal <stal@kirara.ca>2013-09-21 14:47:30 -0700
commitcb68be00b0bb8802da94b877a24e68ee35b5658a (patch)
treebde4de8284321e6ac8f8c61c92b6d5eb399bb9c6 /toxcore/tox.c
parenta6abf007cbb62f0147dd136bffaa9197736b280f (diff)
Change tox_get_friendlist API.
tox_get_friendlist() -> tox_copy_friendlist(). You now have to allocate your own memory to pass into tox_copy_friendlist. To help with this, tox_count_friendlist() has been added to get the length of the friend list.
Diffstat (limited to 'toxcore/tox.c')
-rw-r--r--toxcore/tox.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/toxcore/tox.c b/toxcore/tox.c
index 4fba360b..dfafaf20 100644
--- a/toxcore/tox.c
+++ b/toxcore/tox.c
@@ -262,16 +262,24 @@ void tox_set_sends_receipts(void *tox, int friendnumber, int yesno)
262 m_set_sends_receipts(m, friendnumber, yesno); 262 m_set_sends_receipts(m, friendnumber, yesno);
263} 263}
264 264
265/* Allocate and return a list of valid friend id's. List must be freed by the 265/* Return the number of friends in the instance m.
266 * caller. 266 * You should use this to determine how much memory to allocate
267 * 267 * for copy_friendlist. */
268 * retun 0 if success. 268size_t tox_count_friendlist(void *tox)
269 * return -1 if failure. 269{
270 */ 270 Messenger *m = tox;
271int tox_get_friendlist(void *tox, int **out_list, uint32_t *out_list_length) 271 return count_friendlist(m);
272}
273
274/* Copy a list of valid friend IDs into the array out_list.
275 * If out_list is NULL, returns -1.
276 * Otherwise, returns the number of elements copied.
277 * If the array was too small, the contents
278 * of out_list will be truncated to list_size. */
279size_t tox_copy_friendlist(void *tox, int *out_list, size_t list_size)
272{ 280{
273 Messenger *m = tox; 281 Messenger *m = tox;
274 return get_friendlist(m, out_list, out_list_length); 282 return copy_friendlist(m, out_list, list_size);
275} 283}
276 284
277/* Set the function that will be executed when a friend request is received. 285/* Set the function that will be executed when a friend request is received.