diff options
author | Andreas Schneider <asn@cryptomilk.org> | 2018-02-02 13:06:02 +0100 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2018-06-04 11:20:28 +0200 |
commit | 32c49ea1348b1843ba1829dbaed15382d4c0767d (patch) | |
tree | d0235efb684cf91ddb6ddf949dd3e6314a704c24 /src | |
parent | a465ea2d49539af1d2575498a5ce45e51980d982 (diff) | |
download | libssh-32c49ea1348b1843ba1829dbaed15382d4c0767d.tar.gz libssh-32c49ea1348b1843ba1829dbaed15382d4c0767d.tar.xz libssh-32c49ea1348b1843ba1829dbaed15382d4c0767d.zip |
misc: Add ssh_list_count()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/misc.c | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -397,6 +397,25 @@ struct ssh_iterator *ssh_list_find(const struct ssh_list *list, void *value){ return NULL; } +/** + * @brief Get the number of elements in the list + * + * @param[in] list The list to count. + * + * @return The number of elements in the list. + */ +size_t ssh_list_count(const struct ssh_list *list) +{ + struct ssh_iterator *it = NULL; + int count = 0; + + for (it = ssh_list_get_iterator(list); it != NULL ; it = it->next) { + count++; + } + + return count; +} + static struct ssh_iterator *ssh_iterator_new(const void *data){ struct ssh_iterator *iterator=malloc(sizeof(struct ssh_iterator)); if(!iterator) |