]> xenbits.xensource.com Git - people/andrewcoop/hwloc.git/commitdiff
core: Add add_info_nodup() to optionally check for duplicate info keypairs
authorBrice Goglin <Brice.Goglin@inria.fr>
Wed, 29 Jan 2014 19:51:29 +0000 (20:51 +0100)
committerBrice Goglin <Brice.Goglin@inria.fr>
Wed, 29 Jan 2014 19:52:31 +0000 (20:52 +0100)
include/private/private.h
src/topology.c

index a9009de456fe1d9e307a17ba373c54d3108b041b..5e684b0d62ab74436a1710b9e3f8c19cec74ae59 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright © 2009      CNRS
- * Copyright © 2009-2012 Inria.  All rights reserved.
+ * Copyright © 2009-2014 Inria.  All rights reserved.
  * Copyright © 2009-2012 Université Bordeaux 1
  * Copyright © 2009-2011 Cisco Systems, Inc.  All rights reserved.
  *
@@ -295,4 +295,6 @@ extern int hwloc_namecoloncmp(const char *haystack, const char *needle, size_t n
  * required size.  hwloc_snprintf always report the actually required size. */
 extern int hwloc_snprintf(char *str, size_t size, const char *format, ...) __hwloc_attribute_format(printf, 3, 4);
 
+extern void hwloc_obj_add_info_nodup(hwloc_obj_t obj, const char *name, const char *value, int nodup);
+
 #endif /* HWLOC_PRIVATE_H */
index 31e8231b75b29084281a2533554204ec7fef03c2..f569dc8b5dd47f92d9ac4d262d440e426016e939 100644 (file)
@@ -271,6 +271,13 @@ void hwloc_obj_add_info(hwloc_obj_t obj, const char *name, const char *value)
   obj->infos_count++;
 }
 
+void hwloc_obj_add_info_nodup(hwloc_obj_t obj, const char *name, const char *value, int nodup)
+{
+  if (nodup && hwloc_obj_get_info_by_name(obj, name))
+    return;
+  hwloc_obj_add_info(obj, name, value);
+}
+
 /* Free an object and all its content.  */
 void
 hwloc_free_unlinked_object(hwloc_obj_t obj)