From 91ccba964372add95b41b45a9e5b8bc68cae5b39 Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Thu, 2 Aug 2012 16:29:44 +0000 Subject: [PATCH] Minor enhancements to the hwloc base: * NULL's out the hwloc_obj_t->userdata in hwloc_base_util.c:free_object() and hwloc_base_util.c:opal_hwloc_base_free_topology() after it has been OBJ_RELEASE'd. * Adds a userdata field to opal_hwloc_topo_data_t. This field will be used in an upcoming rmaps component ("lama") to cache some associated data during hardware tree traversals. This commit was SVN r26938. --- opal/mca/hwloc/base/hwloc_base_open.c | 2 ++ opal/mca/hwloc/base/hwloc_base_util.c | 2 ++ opal/mca/hwloc/hwloc.h | 3 +++ 3 files changed, 7 insertions(+) diff --git a/opal/mca/hwloc/base/hwloc_base_open.c b/opal/mca/hwloc/base/hwloc_base_open.c index 3c77320b77..b077074a6f 100644 --- a/opal/mca/hwloc/base/hwloc_base_open.c +++ b/opal/mca/hwloc/base/hwloc_base_open.c @@ -333,6 +333,7 @@ static void topo_data_const(opal_hwloc_topo_data_t *ptr) { ptr->available = NULL; OBJ_CONSTRUCT(&ptr->summaries, opal_list_t); + ptr->userdata = NULL; } static void topo_data_dest(opal_hwloc_topo_data_t *ptr) { @@ -345,6 +346,7 @@ static void topo_data_dest(opal_hwloc_topo_data_t *ptr) OBJ_RELEASE(item); } OBJ_DESTRUCT(&ptr->summaries); + ptr->userdata = NULL; } OBJ_CLASS_INSTANCE(opal_hwloc_topo_data_t, opal_object_t, diff --git a/opal/mca/hwloc/base/hwloc_base_util.c b/opal/mca/hwloc/base/hwloc_base_util.c index 1c8e385a3f..36d06dad02 100644 --- a/opal/mca/hwloc/base/hwloc_base_util.c +++ b/opal/mca/hwloc/base/hwloc_base_util.c @@ -240,6 +240,7 @@ static void free_object(hwloc_obj_t obj) if (NULL != obj->userdata) { data = (opal_hwloc_obj_data_t*)obj->userdata; OBJ_RELEASE(data); + obj->userdata = NULL; } /* loop thru our children */ @@ -259,6 +260,7 @@ void opal_hwloc_base_free_topology(hwloc_topology_t topo) if (NULL != obj->userdata) { rdata = (opal_hwloc_topo_data_t*)obj->userdata; OBJ_RELEASE(rdata); + obj->userdata = NULL; } /* now recursively descend and release userdata * in the rest of the objects diff --git a/opal/mca/hwloc/hwloc.h b/opal/mca/hwloc/hwloc.h index 48574b926f..bb9aa6cb61 100644 --- a/opal/mca/hwloc/hwloc.h +++ b/opal/mca/hwloc/hwloc.h @@ -132,6 +132,9 @@ typedef struct { opal_object_t super; hwloc_cpuset_t available; opal_list_t summaries; + + /** \brief Additional space for custom data */ + void *userdata; } opal_hwloc_topo_data_t; OBJ_CLASS_DECLARATION(opal_hwloc_topo_data_t);