Added pj_list_size()
git-svn-id: https://svn.pjsip.org/repos/pjproject/trunk@192 74dad513-b988-da41-8d7b-12977e46ad98
This commit is contained in:
parent
f239cfa75c
commit
a5f4ff2b39
|
@ -249,6 +249,16 @@ PJ_IDECL(pj_list_type*) pj_list_search(pj_list_type *list, void *value,
|
|||
);
|
||||
|
||||
|
||||
/**
|
||||
* Traverse the list to get the number of elements in the list.
|
||||
*
|
||||
* @param list The list head.
|
||||
*
|
||||
* @return Number of elements.
|
||||
*/
|
||||
PJ_IDECL(pj_size_t) pj_list_size(pj_list_type *list);
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
|
|
@ -116,3 +116,17 @@ pj_list_search(pj_list_type *list, void *value,
|
|||
return p==list ? NULL : p;
|
||||
}
|
||||
|
||||
|
||||
PJ_IDEF(pj_size_t) pj_list_size(pj_list_type *list)
|
||||
{
|
||||
pj_list *node = (pj_list*) ((pj_list*)list)->next;
|
||||
pj_size_t count = 0;
|
||||
|
||||
while (node != list) {
|
||||
++count;
|
||||
node = node->next;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue