1
1

Minor cleanups, mirroring what Jeff did to ompi_info

This commit was SVN r25438.
Этот коммит содержится в:
Ralph Castain 2011-11-05 00:42:49 +00:00
родитель 38451d4972
Коммит 729935dffb

Просмотреть файл

@ -61,7 +61,7 @@ void orte_info_out(const char *pretty_message, const char *plain_message, const
size_t i, len, max_value_width; size_t i, len, max_value_width;
char *spaces = NULL; char *spaces = NULL;
char *filler = NULL; char *filler = NULL;
char *pos, *v, savev; char *pos, *v, savev, *v_to_free;
#ifdef HAVE_ISATTY #ifdef HAVE_ISATTY
/* If we have isatty(), if this is not a tty, then disable /* If we have isatty(), if this is not a tty, then disable
@ -82,7 +82,7 @@ void orte_info_out(const char *pretty_message, const char *plain_message, const
#endif #endif
/* Strip leading and trailing whitespace from the string value */ /* Strip leading and trailing whitespace from the string value */
v = strdup(value); v = v_to_free = strdup(value);
len = strlen(v); len = strlen(v);
if (isspace(v[0])) { if (isspace(v[0])) {
char *newv; char *newv;
@ -91,8 +91,8 @@ void orte_info_out(const char *pretty_message, const char *plain_message, const
++i; ++i;
} }
newv = strdup(v + i); newv = strdup(v + i);
free(v); free(v_to_free);
v = newv; v_to_free = v = newv;
len = strlen(v); len = strlen(v);
} }
if (len > 0 && isspace(v[len - 1])) { if (len > 0 && isspace(v[len - 1])) {
@ -188,6 +188,9 @@ void orte_info_out(const char *pretty_message, const char *plain_message, const
printf(" %s\n", value); printf(" %s\n", value);
} }
} }
if (NULL != v_to_free) {
free(v_to_free);
}
} }
void orte_info_out_int(const char *pretty_message, void orte_info_out_int(const char *pretty_message,