summaryrefslogtreecommitdiff
path: root/src/common/lists.c
diff options
context:
space:
mode:
authorOndřej Surý <ondrej@sury.org>2013-06-28 12:59:40 +0200
committerOndřej Surý <ondrej@sury.org>2013-06-28 12:59:40 +0200
commit124965832295a277b9ca6ae9fac4f45a74a36b2a (patch)
treef299e2335863f74e0be0707f84b85211baaf2d03 /src/common/lists.c
parent3d2d198c71a6b844b60fa9ef68801b66bba93361 (diff)
downloadknot-upstream/1.3.0_rc3.tar.gz
New upstream version 1.3.0~rc3upstream/1.3.0_rc3
Diffstat (limited to 'src/common/lists.c')
-rw-r--r--src/common/lists.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/common/lists.c b/src/common/lists.c
index 9a93733..e629e9d 100644
--- a/src/common/lists.c
+++ b/src/common/lists.c
@@ -26,6 +26,7 @@
#define _BIRD_LISTS_C_
+#include <config.h>
#include <stdlib.h>
#include <string.h>
#include "common/lists.h"
@@ -158,3 +159,21 @@ void list_dup(list *dst, list *src, size_t itemsz)
add_tail(dst, i);
}
}
+
+/**
+ * list_size - gets number of nodes
+ * @l: list
+ *
+ * This function counts nodes in list @l and returns this number.
+ */
+size_t list_size(const list *l)
+{
+ size_t count = 0;
+
+ node *n = 0;
+ WALK_LIST(n, *l) {
+ count++;
+ }
+
+ return count;
+}