Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F139486102
D3371.id7911.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D3371.id7911.diff
View Options
Index: share/man/man3/tree.3
===================================================================
--- share/man/man3/tree.3
+++ share/man/man3/tree.3
@@ -30,7 +30,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd January 24, 2015
+.Dd August 12, 2015
.Dt TREE 3
.Os
.Sh NAME
@@ -95,6 +95,7 @@
.Nm RB_FOREACH_REVERSE_SAFE ,
.Nm RB_INIT ,
.Nm RB_INSERT ,
+.Nm RB_NUMNODES ,
.Nm RB_REMOVE
.Nd "implementations of splay and red-black trees"
.Sh SYNOPSIS
@@ -186,6 +187,8 @@
.Fn RB_INSERT NAME "RB_HEAD *head" "struct TYPE *elm"
.Ft "struct TYPE *"
.Fn RB_REMOVE NAME "RB_HEAD *head" "struct TYPE *elm"
+.Ft void
+.Fn RB_NUMNODES "TYPE" "NAME" "RB_HEAD *head" "COUNTER"
.Sh DESCRIPTION
These macros define data structures for different types of trees:
splay trees and red-black trees.
@@ -557,6 +560,14 @@
The
.Fn RB_EMPTY
macro should be used to check whether a red-black tree is empty.
+.Pp
+The
+.Fn RB_NUMNODES
+macro traverse the tree referenced by
+.Ar head
+counting the number of nodes.
+.Ar COUNTER
+is initialized to 0 before traversing and incremented by one for each nodes.
.Sh NOTES
Trying to free a tree in the following way is a common error:
.Bd -literal -offset indent
Index: sys/sys/tree.h
===================================================================
--- sys/sys/tree.h
+++ sys/sys/tree.h
@@ -798,4 +798,12 @@
((x) != NULL) && ((y) = name##_RB_PREV(x), (x) != NULL); \
(x) = (y))
+#define RB_NUMNODES(type, name, head, cnt) do { \
+ type *t; \
+ cnt = 0; \
+ RB_FOREACH(t, name, head) { \
+ cnt++; \
+ } \
+} while (0);
+
#endif /* _SYS_TREE_H_ */
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Dec 13, 3:53 PM (7 h, 50 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
26934851
Default Alt Text
D3371.id7911.diff (1 KB)
Attached To
Mode
D3371: Add RB_NUMNODES in tree(3)
Attached
Detach File
Event Timeline
Log In to Comment