+/* "Safe" version of strcmp(3): Either or both pointers may be NULL. */
+static int strcmp_s (const char *s1, const char *s2) /* {{{ */
+{
+ if ((s1 == NULL) && (s2 == NULL))
+ return (0);
+ else if (s1 == NULL)
+ return (1);
+ else if (s2 == NULL)
+ return (-1);
+ assert ((s1 != NULL) && (s2 != NULL));
+
+ return (strcmp (s1, s2));
+} /* }}} int strcmp_s */
+
+static int gl_compare (const void *p0, const void *p1) /* {{{ */
+{
+ const graph_list_t *gl0 = p0;
+ const graph_list_t *gl1 = p1;
+ int status;
+
+ status = strcmp (gl0->host, gl1->host);
+ if (status != 0)
+ return (status);
+
+ status = strcmp (gl0->plugin, gl1->plugin);
+ if (status != 0)
+ return (status);
+
+ status = strcmp_s (gl0->plugin_instance, gl1->plugin_instance);
+ if (status != 0)
+ return (status);
+
+ status = strcmp (gl0->type, gl1->type);
+ if (status != 0)
+ return (status);
+
+ return (strcmp_s (gl0->type_instance, gl1->type_instance));
+} /* }}} int gl_compare */
+