mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-07 09:43:56 -06:00
qlist: add qlist_size()
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
5a4d701acd
commit
a86a4c2f7b
2 changed files with 14 additions and 0 deletions
13
qlist.c
13
qlist.c
|
@ -124,6 +124,19 @@ int qlist_empty(const QList *qlist)
|
|||
return QTAILQ_EMPTY(&qlist->head);
|
||||
}
|
||||
|
||||
static void qlist_size_iter(QObject *obj, void *opaque)
|
||||
{
|
||||
size_t *count = opaque;
|
||||
(*count)++;
|
||||
}
|
||||
|
||||
size_t qlist_size(const QList *qlist)
|
||||
{
|
||||
size_t count = 0;
|
||||
qlist_iter(qlist, qlist_size_iter, &count);
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* qobject_to_qlist(): Convert a QObject into a QList
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue