--- hwloc-0.9.2/include/private/private.h 2009-11-03 16:40:30.000000000 -0600 +++ hwloc-new//include/private/private.h 2009-11-19 15:28:37.439941339 -0600 @@ -201,4 +201,6 @@ * required size. hwloc_snprintf always report the actually required size. */ int hwloc_snprintf(char *str, size_t size, const char *format, ...); +void hwloc_free_object(hwloc_obj_t obj); + #endif /* HWLOC_PRIVATE_H */ --- hwloc-0.9.2/src/topology.c 2009-11-03 16:40:31.000000000 -0600 +++ hwloc-new//src/topology.c 2009-11-20 08:10:01.537850444 -0600 @@ -383,8 +383,8 @@ } /* Free an object and all its content. */ -static void -free_object(hwloc_obj_t obj) +void +hwloc_free_object(hwloc_obj_t obj) { switch (obj->type) { case HWLOC_OBJ_SYSTEM: @@ -676,7 +676,7 @@ hwloc_add_object(struct hwloc_topology *topology, hwloc_obj_t obj) { if (topology->ignored_types[obj->type] == HWLOC_IGNORE_TYPE_ALWAYS) { - free_object(obj); + hwloc_free_object(obj); return; } @@ -740,7 +740,7 @@ static void do_free_object(hwloc_topology_t topology, hwloc_obj_t *obj, void *data) { - free_object(*obj); + hwloc_free_object(*obj); } /* Remove all children whose cpuset is empty, except NUMA nodes @@ -772,11 +772,11 @@ /* Father can be ignored in favor of the child. */ *pfather = child; child->next_sibling = father->next_sibling; - free_object(father); + hwloc_free_object(father); } else if (topology->ignored_types[child->type] == HWLOC_IGNORE_TYPE_KEEP_STRUCTURE) { /* Child can be ignored in favor of the father. */ father->first_child = child->first_child; - free_object(child); + hwloc_free_object(child); } } @@ -1296,7 +1296,7 @@ unsigned l,i; for (l=0; lnb_levels; l++) { for (i=0; ilevel_nbobjects[l]; i++) - free_object(topology->levels[l][i]); + hwloc_free_object(topology->levels[l][i]); free(topology->levels[l]); } } --- hwloc-0.9.2/src/topology-linux.c 2009-11-03 16:40:31.000000000 -0600 +++ hwloc-new//src/topology-linux.c 2009-11-20 08:13:02.418548959 -0600 @@ -582,11 +582,14 @@ node->cpuset = cpuset; node->attr->node.memory_kB = size; node->attr->node.huge_page_free = hpfree; - node->cpuset = cpuset; hwloc_debug_1arg_cpuset("os node %u has cpuset %s\n", osnode, node->cpuset); - hwloc_add_object(topology, node); + + /* Might free the object and we need it in the misc calculations */ + if (topology->ignored_types[HWLOC_OBJ_NODE] != + HWLOC_IGNORE_TYPE_ALWAYS) + hwloc_add_object(topology, node); nodes[osnode] = node; sprintf(nodepath, "%s/node%u/distance", path, osnode); @@ -594,6 +597,13 @@ } hwloc_setup_misc_level_from_distances(topology, nbnodes, nodes, (unsigned*) distances); + /* No longer need the node objects */ + if (topology->ignored_types[HWLOC_OBJ_NODE] == HWLOC_IGNORE_TYPE_ALWAYS) { + int i; + for (i = 0; i < nbnodes; i++) { + hwloc_free_object(nodes[i]); + } + } } }