From c83ef674e359f8ca31249ed7d885968ca42bea04 Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Fri, 13 Feb 2009 03:44:29 +0000 Subject: [PATCH] Some minor valgrind-inspired cleanups: fix some memory leaks. Also took the opprotunity to convert the rdma mpool to use the MCA register function. This commit was SVN r20541. --- ompi/mca/mpool/rdma/mpool_rdma_component.c | 37 +++++++++++++++++----- ompi/mca/mpool/sm/mpool_sm_component.c | 17 ++++++++-- 2 files changed, 44 insertions(+), 10 deletions(-) diff --git a/ompi/mca/mpool/rdma/mpool_rdma_component.c b/ompi/mca/mpool/rdma/mpool_rdma_component.c index 3859241522..73bd96968a 100644 --- a/ompi/mca/mpool/rdma/mpool_rdma_component.c +++ b/ompi/mca/mpool/rdma/mpool_rdma_component.c @@ -10,7 +10,7 @@ * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. * Copyright (c) 2006 Voltaire. All rights reserved. - * Copyright (c) 2007-2008 Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2007-2009 Cisco Systems, Inc. All rights reserved. * * $COPYRIGHT$ * @@ -35,8 +35,10 @@ /* * Local functions */ -static int mca_mpool_rdma_open(void); -static mca_mpool_base_module_t* mca_mpool_rdma_init( +static int rdma_open(void); +static int rdma_close(void); +static int rdma_register(void); +static mca_mpool_base_module_t* rdma_init( struct mca_mpool_base_resources_t* resources); mca_mpool_rdma_component_t mca_mpool_rdma_component = { @@ -51,22 +53,30 @@ mca_mpool_rdma_component_t mca_mpool_rdma_component = { OMPI_MAJOR_VERSION, /* MCA component major version */ OMPI_MINOR_VERSION, /* MCA component minor version */ OMPI_RELEASE_VERSION, /* MCA component release version */ - mca_mpool_rdma_open, /* component open */ - NULL + rdma_open, /* component open */ + rdma_close, + NULL, + rdma_register }, { /* The component is checkpoint ready */ MCA_BASE_METADATA_PARAM_CHECKPOINT }, - mca_mpool_rdma_init + rdma_init } }; /** * component open/close/init function */ -static int mca_mpool_rdma_open(void) +static int rdma_open(void) +{ + return OMPI_SUCCESS; +} + + +static int rdma_register(void) { int val; @@ -92,7 +102,18 @@ static int mca_mpool_rdma_open(void) return OMPI_SUCCESS; } -static mca_mpool_base_module_t* mca_mpool_rdma_init( + +static int rdma_close(void) +{ + if (NULL != mca_mpool_rdma_component.rcache_name) { + free(mca_mpool_rdma_component.rcache_name); + } + + return OMPI_SUCCESS; +} + + +static mca_mpool_base_module_t* rdma_init( struct mca_mpool_base_resources_t *resources) { mca_mpool_rdma_module_t* mpool_module; diff --git a/ompi/mca/mpool/sm/mpool_sm_component.c b/ompi/mca/mpool/sm/mpool_sm_component.c index 4911e0a83b..4d27550690 100644 --- a/ompi/mca/mpool/sm/mpool_sm_component.c +++ b/ompi/mca/mpool/sm/mpool_sm_component.c @@ -10,7 +10,7 @@ * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. * Copyright (c) 2007-2009 Sun Microsystems, Inc. All rights reserved. - * Copyright (c) 2008 Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2008-2009 Cisco Systems, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -72,7 +72,7 @@ mca_mpool_sm_component_t mca_mpool_sm_component = { } }; -static char *max_size_param, *min_size_param, *peer_size_param; +static char *max_size_param = NULL, *min_size_param = NULL, *peer_size_param = NULL; static long default_max, default_min, default_peer; #if SIZEOF_LONG == 4 @@ -163,6 +163,19 @@ static int mca_mpool_sm_close( void ) } OBJ_RELEASE( mca_common_sm_mmap ); } + + if (NULL != mca_mpool_sm_component.sm_allocator_name) { + free(mca_mpool_sm_component.sm_allocator_name); + } + if (NULL != max_size_param) { + free(max_size_param); + } + if (NULL != min_size_param) { + free(min_size_param); + } + if (NULL != peer_size_param) { + free(peer_size_param); + } return OMPI_SUCCESS; }