[kdbus] KDBUS_ITEM_PAYLOAD_OFF items are (once again) relative to msg header
[platform/upstream/glib.git] / glib / gnode.c
index 22d1937..b529f48 100644 (file)
@@ -15,9 +15,7 @@
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  */
 
 /*
 
 #include "gnode.h"
 
+#include "gslice.h"
+
 #include "gtestutils.h"
 
 /**
- * SECTION: trees-nary
+ * SECTION:trees-nary
  * @title: N-ary Trees
  * @short_description: trees of data with any number of branches
  *
@@ -51,8 +51,9 @@
  * g_node_insert_before(), g_node_append() and g_node_prepend().
  *
  * To create a new node and insert it into a tree use
- * g_node_insert_data(), g_node_insert_data_before(),
- * g_node_append_data() and g_node_prepend_data().
+ * g_node_insert_data(), g_node_insert_data_after(),
+ * g_node_insert_data_before(), g_node_append_data()
+ * and g_node_prepend_data().
  *
  * To reverse the children of a node use g_node_reverse_children().
  *
  *            children are accessed by using the @next pointer of each
  *            child.
  *
- * The #GNode struct represents one node in a
- * <link linkend="glib-N-ary-Trees">N-ary Tree</link>. fields
- **/
-
-/**
- * g_node_push_allocator:
- * @dummy: the #GAllocator to use when allocating #GNode elements.
- *
- * Sets the allocator to use to allocate #GNode elements. Use
- * g_node_pop_allocator() to restore the previous allocator.
- *
- * Note that this function is not available if GLib has been compiled
- * with <option>--disable-mem-pools</option>
- *
- * Deprecated:2.10: It does nothing, since #GNode has been converted to
- *                  the <link linkend="glib-Memory-Slices">slice
- *                  allocator</link>
- **/
-void g_node_push_allocator (gpointer dummy) { /* present for binary compat only */ }
-
-/**
- * g_node_pop_allocator:
- *
- * Restores the previous #GAllocator, used when allocating #GNode
- * elements.
- *
- * Note that this function is not available if GLib has been compiled
- * with <option>--disable-mem-pools</option>
- *
- * Deprecated:2.10: It does nothing, since #GNode has been converted to
- *                  the <link linkend="glib-Memory-Slices">slice
- *                  allocator</link>
+ * The #GNode struct represents one node in a [n-ary tree][glib-N-ary-Trees].
  **/
-void g_node_pop_allocator  (void)           { /* present for binary compat only */ }
 
 #define g_node_alloc0()         g_slice_new0 (GNode)
 #define g_node_free(node)       g_slice_free (GNode, node)
@@ -205,7 +174,7 @@ g_node_unlink (GNode *node)
  * 
  * Recursively copies a #GNode and its data.
  * 
- * Return value: a new #GNode containing copies of the data in @node.
+ * Returns: a new #GNode containing copies of the data in @node.
  *
  * Since: 2.4
  **/
@@ -848,6 +817,35 @@ g_node_depth_traverse_level (GNode             *node,
  * It calls the given function for each node visited.
  * The traversal can be halted at any point by returning %TRUE from @func.
  */
+
+/**
+ * GTraverseType:
+ * @G_IN_ORDER: vists a node's left child first, then the node itself,
+ *              then its right child. This is the one to use if you
+ *              want the output sorted according to the compare
+ *              function.
+ * @G_PRE_ORDER: visits a node, then its children.
+ * @G_POST_ORDER: visits the node's children, then the node itself.
+ * @G_LEVEL_ORDER: is not implemented for
+ *              [balanced binary trees][glib-Balanced-Binary-Trees].
+ *              For [n-ary trees][glib-N-ary-Trees], it
+ *              vists the root node first, then its children, then
+ *              its grandchildren, and so on. Note that this is less
+ *              efficient than the other orders.
+ *
+ * Specifies the type of traveral performed by g_tree_traverse(),
+ * g_node_traverse() and g_node_find(). The different orders are
+ * illustrated here:
+ * - In order: A, B, C, D, E, F, G, H, I
+ *   ![](Sorted_binary_tree_inorder.svg)
+ * - Pre order: F, B, A, D, C, E, G, I, H
+ *   ![](Sorted_binary_tree_preorder.svg)
+ * - Post order: A, C, E, D, B, H, I, G, F
+ *   ![](Sorted_binary_tree_postorder.svg)
+ * - Level order: F, B, G, A, D, I, C, E, H
+ *   ![](Sorted_binary_tree_breadth-first_traversal.svg)
+ */
+
 /**
  * GTraverseFlags:
  * @G_TRAVERSE_LEAVES: only leaf nodes should be visited. This name has
@@ -868,12 +866,13 @@ g_node_depth_traverse_level (GNode             *node,
  * GNodeTraverseFunc:
  * @node: a #GNode.
  * @data: user data passed to g_node_traverse().
- * @Returns: %TRUE to stop the traversal.
  *
  * Specifies the type of function passed to g_node_traverse(). The
  * function is called with each of the nodes visited, together with the
  * user data passed to g_node_traverse(). If the function returns
  * %TRUE, then the traversal is stopped.
+ *
+ * Returns: %TRUE to stop the traversal.
  **/
 void
 g_node_traverse (GNode           *root,