[ofa-general] [PATCH] opensm/osm_ucast_lash.(h c): Replace memory allocation by array
Hal Rosenstock
hnrose at comcast.net
Wed Jun 17 13:09:11 PDT 2009
lash's num_mst_in_lane array is indexed by lane nuber, not by switch index.
Since it's a small number, get rid of extra memory allocation.
Signed-off-by: Robert Pearson <rpearson at systemfabricworks.com>
Signed-off-by: Hal Rosenstock <hal.rosenstock at gmail.com>
---
diff --git a/opensm/include/opensm/osm_ucast_lash.h b/opensm/include/opensm/osm_ucast_lash.h
index f48ea33..98034cc 100644
--- a/opensm/include/opensm/osm_ucast_lash.h
+++ b/opensm/include/opensm/osm_ucast_lash.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008 System Fabric Works, Inc.
+ * Copyright (c) 2008,2009 System Fabric Works, Inc. All rights reserved.
* Copyright (c) 2004-2007 Voltaire, Inc. All rights reserved.
* Copyright (c) 2002-2006 Mellanox Technologies LTD. All rights reserved.
* Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
@@ -90,7 +90,7 @@ typedef struct _lash {
int balance_limit;
switch_t **switches;
cdg_vertex_t ****cdg_vertex_matrix;
- int *num_mst_in_lane;
+ int num_mst_in_lane[IB_MAX_NUM_VLS];
int ***virtual_location;
} lash_t;
diff --git a/opensm/opensm/osm_ucast_lash.c b/opensm/opensm/osm_ucast_lash.c
index a987eb3..d8f0ac3 100644
--- a/opensm/opensm/osm_ucast_lash.c
+++ b/opensm/opensm/osm_ucast_lash.c
@@ -4,6 +4,7 @@
* Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
* Copyright (c) 2007 Simula Research Laboratory. All rights reserved.
* Copyright (c) 2007 Silicon Graphics Inc. All rights reserved.
+ * Copyright (c) 2008,2009 System Fabric Works, Inc. 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
@@ -707,9 +708,6 @@ static void free_lash_structures(lash_t * p_lash)
if (p_lash->virtual_location)
free(p_lash->virtual_location);
- if (p_lash->num_mst_in_lane)
- free(p_lash->num_mst_in_lane);
-
OSM_LOG_EXIT(p_log);
}
@@ -778,11 +776,7 @@ static int init_lash_structures(lash_t * p_lash)
}
/* initialise num_mst_in_lane[num_switches], default 0 */
- p_lash->num_mst_in_lane = (int *)malloc(num_switches * sizeof(int));
- if (p_lash->num_mst_in_lane == NULL)
- goto Exit_Mem_Error;
- memset(p_lash->num_mst_in_lane, 0,
- num_switches * sizeof(p_lash->num_mst_in_lane[0]));
+ memset(p_lash->num_mst_in_lane, 0, IB_MAX_NUM_VLS);
goto Exit;
More information about the general
mailing list