2nd info column):

Duplicate col_do_append_sep_va_fstr()'s code into col_append_fstr() and
col_append_sep_fstr() (and remove col_do_append_sep_va_fstr()) because we need
to call va_start() and va_end() after each call to g_vsnprintf().  (This is a
followon to rev 32961.)

svn path=/trunk/; revision=33472
This commit is contained in:
Jeff Morriss 2010-07-08 02:54:26 +00:00
parent 4e76ef92cb
commit b0cf38c06c
1 changed files with 54 additions and 40 deletions

View File

@ -253,22 +253,68 @@ col_custom_prime_edt(epan_dissect_t *edt, column_info *cinfo)
}
}
static void
col_do_append_sep_va_fstr(column_info *cinfo, const gint el, const gchar *separator,
const gchar *format, va_list ap)
/* Appends a vararg list to a packet info string.
* This function's code is duplicated in col_append_sep_fstr() below because
* the for() loop below requires us to call va_start/va_end so intermediate
* functions are a problem.
*/
void
col_append_fstr(column_info *cinfo, const gint el, const gchar *format, ...)
{
int i;
int len, max_len, sep_len;
int len, max_len;
va_list ap;
if (!CHECK_COL(cinfo, el))
return;
if (el == COL_INFO)
max_len = COL_MAX_INFO_LEN;
else
max_len = COL_MAX_LEN;
for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) {
if (cinfo->fmt_matx[i][el]) {
/*
* First arrange that we can append, if necessary.
*/
COL_CHECK_APPEND(cinfo, i, max_len);
len = (int) strlen(cinfo->col_buf[i]);
va_start(ap, format);
g_vsnprintf(&cinfo->col_buf[i][len], max_len - len, format, ap);
va_end(ap);
}
}
}
/* Appends a vararg list to a packet info string.
* Prefixes it with the given separator if the column is not empty.
* Code is duplicated from col_append_fstr above().
*/
void
col_append_sep_fstr(column_info *cinfo, const gint el, const gchar *separator,
const gchar *format, ...)
{
int i;
int len, max_len, sep_len;
va_list ap;
if (!CHECK_COL(cinfo, el))
return;
if (separator == NULL)
sep_len = 0;
separator = ", "; /* default */
sep_len = (int) strlen(separator);
if (el == COL_INFO)
max_len = COL_MAX_INFO_LEN;
else
sep_len = (int) strlen(separator);
max_len = COL_MAX_LEN;
for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) {
if (cinfo->fmt_matx[i][el]) {
/*
@ -287,45 +333,13 @@ col_do_append_sep_va_fstr(column_info *cinfo, const gint el, const gchar *separa
len += sep_len;
}
}
va_start(ap, format);
g_vsnprintf(&cinfo->col_buf[i][len], max_len - len, format, ap);
va_end(ap);
}
}
}
/* Appends a vararg list to a packet info string. */
void
col_append_fstr(column_info *cinfo, const gint el, const gchar *format, ...)
{
va_list ap;
if (!CHECK_COL(cinfo, el))
return;
va_start(ap, format);
col_do_append_sep_va_fstr(cinfo, el, NULL, format, ap);
va_end(ap);
}
/* Appends a vararg list to a packet info string.
* Prefixes it with the given separator if the column is not empty. */
void
col_append_sep_fstr(column_info *cinfo, const gint el, const gchar *separator,
const gchar *format, ...)
{
va_list ap;
if (!CHECK_COL(cinfo, el))
return;
if (separator == NULL)
separator = ", "; /* default */
va_start(ap, format);
col_do_append_sep_va_fstr(cinfo, el, separator, format, ap);
va_end(ap);
}
/* Prepends a vararg list to a packet info string. */
#define COL_BUF_MAX_LEN (((COL_MAX_INFO_LEN) > (COL_MAX_LEN)) ? \
(COL_MAX_INFO_LEN) : (COL_MAX_LEN))