Simplify xmalloc expressions. Add overflow check in xmalloc arguments.
[gnulib.git] / lib / gl_avltree_oset.c
index db02ab8..1e38b98 100644 (file)
@@ -310,8 +310,7 @@ static gl_oset_node_t
 gl_tree_add_first (gl_oset_t set, const void *elt)
 {
   /* Create new node.  */
-  gl_oset_node_t new_node =
-    (struct gl_oset_node_impl *) xmalloc (sizeof (struct gl_oset_node_impl));
+  gl_oset_node_t new_node = XMALLOC (struct gl_oset_node_impl);
 
   new_node->left = NULL;
   new_node->right = NULL;
@@ -348,8 +347,7 @@ static gl_oset_node_t
 gl_tree_add_before (gl_oset_t set, gl_oset_node_t node, const void *elt)
 {
   /* Create new node.  */
-  gl_oset_node_t new_node =
-    (struct gl_oset_node_impl *) xmalloc (sizeof (struct gl_oset_node_impl));
+  gl_oset_node_t new_node = XMALLOC (struct gl_oset_node_impl);
   bool height_inc;
 
   new_node->left = NULL;
@@ -386,8 +384,7 @@ static gl_oset_node_t
 gl_tree_add_after (gl_oset_t set, gl_oset_node_t node, const void *elt)
 {
   /* Create new node.  */
-  gl_oset_node_t new_node =
-    (struct gl_oset_node_impl *) xmalloc (sizeof (struct gl_oset_node_impl));
+  gl_oset_node_t new_node = XMALLOC (struct gl_oset_node_impl);
   bool height_inc;
 
   new_node->left = NULL;