Wireshark-dev: Re: [Wireshark-dev] Column data memory allocation - excessive?

From: Stephen Fisher <stephentfisher@xxxxxxxxx>
Date: Sun, 2 Mar 2008 16:20:37 -0700
On Sun, Mar 02, 2008 at 02:44:21PM -0800, Guy Harris wrote:
> Stephen Fisher wrote:
> > One place where there are a lot of calls to the unsafe strcpy() is 
> > epan/column-utils.c.  However, before replacing them with g_strpcpy(), I 
> > wanted to ask if there is any reason we can't start using dynamic memory 
> > allocation in those places (as Guy recently suggested) instead of 
> > g_strlcpy()?
> 
> I'm not sure I'd suggested that - I've mainly been concerned about the 
> memory allocation internal to GTK+ for the column displays, rather 
> than stuff Wireshark itself allocates.

Oh, ok.

> > We are allocating full field widths worth of memory for every column 
> > (256 bytes each) plus the info column (4096 bytes each) for every row in 
> > the build_column_format_array() function (in epan/column.c) ahead of 
> > time and then strcpy() data into them.
> 
> For every row?  I might be misremembering, but I think only one set of 
> column string buffers are allocated at start-up time, and those 
> buffers are reused.

Whew!  You're right.  Thanks for the insight.  I'll go ahead and convert 
strcpy() to g_strlcpy() in epan/column-utils.c then.


Steve