]> git.ozlabs.org Git - ccan/blobdiff - ccan/rbtree/rbtree.c
base64: fix for unsigned chars (e.g. ARM).
[ccan] / ccan / rbtree / rbtree.c
index e3b4a9518fe0b64537c5933c30ab8578b10c46c8..8a59b76ba6fe5a07ef277ab295d91959a3be4d7c 100644 (file)
@@ -48,9 +48,9 @@ static int tree_destructor(trbt_tree_t *tree)
        }
 
        /* traverse the tree and remove the node destructor then delete it.
-          we dont want to use the existing destructor for the node
+          we don't want to use the existing destructor for the node
           since that will remove the nodes one by one from the tree.
-          since the entire tree will be completely destroyed we dont care
+          since the entire tree will be completely destroyed we don't care
           if it is inconsistent or unbalanced while freeing the
           individual nodes
        */
@@ -448,7 +448,7 @@ delete_node(trbt_node_t *node)
           predecessor instead.
           The predecessor is guaranteed to have at most one child
           node since its right arm must be NULL
-          (It must be NULL since we are its sucessor and we are above
+          (It must be NULL since we are its successor and we are above
            it in the tree)
         */
        if (node->left != NULL && node->right != NULL) {
@@ -489,7 +489,7 @@ delete_node(trbt_node_t *node)
           Once the delete of the node is finished, we remove this dummy
           node, which is simple to do since it is guaranteed that it will
           still not have any children after the delete operation.
-          This is because we dont represent the leaf-nodes as actual nodes
+          This is because we don't represent the leaf-nodes as actual nodes
           in this implementation.
         */
        if (!child) {
@@ -528,7 +528,7 @@ delete_node(trbt_node_t *node)
           This is simple since this dummy node originally had no children
           and we are guaranteed that it will also not have any children
           after the node has been deleted and any possible rotations
-          have occured.
+          have occurred.
 
           The only special case is if this was the last node of the tree
           in which case we have to reset the root to NULL as well.
@@ -671,6 +671,8 @@ trbt_insert32(trbt_tree_t *tree, uint32_t key, void *data)
                                trbt_node_t *new_node;
 
                                new_node = trbt_create_node(tree, node, key, data);
+                               if (!new_node)
+                                       return NULL;
                                node->left=new_node;
                                node=new_node;
 
@@ -685,6 +687,8 @@ trbt_insert32(trbt_tree_t *tree, uint32_t key, void *data)
                                trbt_node_t *new_node;
 
                                new_node = trbt_create_node(tree, node, key, data);
+                               if (!new_node)
+                                       return NULL;
                                node->right=new_node;
                                node=new_node;
                                break;