[ofa-general] [PATCH] opensm/osm_mcast_tbl.c: In osm_mcast_tbl_init, use calloc

Hal Rosenstock hnrose at comcast.net
Tue Jul 7 07:00:07 PDT 2009


rather than malloc/memset

Signed-off-by: Hal Rosenstock <hal.rosenstock at gmail.com>
---
diff --git a/opensm/opensm/osm_mcast_tbl.c b/opensm/opensm/osm_mcast_tbl.c
index 17fb69c..82850be 100644
--- a/opensm/opensm/osm_mcast_tbl.c
+++ b/opensm/opensm/osm_mcast_tbl.c
@@ -2,6 +2,7 @@
  * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
  * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
  * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2009 HNR Consulting. All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
@@ -93,16 +94,13 @@ osm_mcast_tbl_init(IN osm_mcast_tbl_t * const p_tbl,
 	   since it is (and must be) defined that way the table structure
 	   in order to create a pointer to a two dimensional array.
 	 */
-	p_tbl->p_mask_tbl = malloc(p_tbl->num_entries *
+	p_tbl->p_mask_tbl = calloc(p_tbl->num_entries,
 				   (IB_MCAST_POSITION_MAX +
 				    1) * IB_MCAST_MASK_SIZE / 8);
 
 	if (p_tbl->p_mask_tbl == NULL)
 		return (IB_INSUFFICIENT_MEMORY);
 
-	memset(p_tbl->p_mask_tbl, 0,
-	       p_tbl->num_entries * (IB_MCAST_POSITION_MAX +
-				     1) * IB_MCAST_MASK_SIZE / 8);
 	return (IB_SUCCESS);
 }
 



More information about the general mailing list