Changes get_addr_name_buf() to use the more common convention where the provided buffer size is the entire size of the buffer including the space for the terminating \0

svn path=/trunk/; revision=23016
This commit is contained in:
Mike Duigou 2007-09-28 18:23:59 +00:00
parent f4e9824c46
commit 6aeb75c3f0
3 changed files with 6 additions and 11 deletions

View File

@ -2132,14 +2132,9 @@ const gchar *get_addr_name(address *addr)
void get_addr_name_buf(address *addr, gchar *buf, guint size)
{
const gchar *result;
result = get_addr_name(addr);
strncpy(buf,result,size);
buf[size]='\0';
return;
const gchar *result = get_addr_name(addr);
g_snprintf(buf, size, "%s", result);
} /* get_addr_name_buf */

View File

@ -109,9 +109,9 @@ extern gchar *get_sctp_port(guint port);
const gchar *get_addr_name(address *addr);
/* get_addr_name_buf solves an address in the same way as get_addr_name above */
/* The difference is that get_addr_name_buf takes as input a buffer, in which it puts */
/* the result, and a maximum string length -size-. the buffer should be large enough to */
/* contain size characters plus the terminator */
/* The difference is that get_addr_name_buf takes as input a buffer, into which it puts */
/* the result which is always NUL ('\0') terminated. The buffer should be large enough to */
/* contain size characters including the terminator */
void get_addr_name_buf(address *addr, gchar *buf, guint size);

View File

@ -922,7 +922,7 @@ col_set_addr(packet_info *pinfo, int col, address *addr, gboolean is_res,
return; /* no address, nothing to do */
if (is_res) {
get_addr_name_buf(addr, pinfo->cinfo->col_buf[col],COL_MAX_LEN-1);
get_addr_name_buf(addr, pinfo->cinfo->col_buf[col],COL_MAX_LEN);
} else {
switch (addr->type) {